User:Ungoliant MMDCCLXIV/monobook.js

importScript("User:Yair rand/FindTrans.js"); importScript("User:Ungoliant MMDCCLXIV/cathoister.js");

function add_translation_tables { var trans_sections = [];

var text = document.editform.wpTextbox1.value;

function cleanup_gloss(gloss) { if (gloss.indexOf("{{lb") != -1 || gloss.indexOf("{{cx") != -1 || gloss.indexOf("{{context") != -1 || gloss.indexOf("{{label") != -1) { gloss = gloss.slice(gloss.indexOf("}}") + 3); }		while (true) { var taxlink_pos = gloss.indexOf("{{taxlink"); if (taxlink_pos == -1) break; gloss = gloss.slice(0, taxlink_pos) + gloss.slice(taxlink_pos+10, gloss.indexOf("|", taxlink_pos+10)) + gloss.slice(gloss.indexOf("}}", taxlink_pos+10) + 2); }		gloss = gloss.trim; gloss = gloss.replace(/(\{\{l\/en|\{|\}|\]|\[)/g, ""); while (true) { var pipe_pos = gloss.indexOf("|"); if (pipe_pos == -1) break; gloss = gloss.slice(0, gloss.lastIndexOf(" ", pipe_pos - 1)+1) + gloss.slice(pipe_pos+1); }		gloss = gloss.charAt(0).toLowerCase + gloss.slice(1); if (gloss.charAt(gloss.length - 1) == ".") gloss = gloss.slice(0, gloss.length - 1);

return gloss; }

var defline, hash_position, nl_position = -1; while (true) { hash_position = text.indexOf("#", nl_position+1); if (hash_position == -1) break; nl_position = text.indexOf("\n", hash_position+1); if (text.charAt(hash_position+1) != ":" && text.charAt(hash_position+1) != "*") { trans_sections[trans_sections.length] = cleanup_gloss(text.slice(hash_position + 1, nl_position)); }	}

var line_pos1, line_pos2 = text.length; while (true) { line_pos1 = text.lastIndexOf("\n", line_pos2-1); if (line_pos1 == -1) break; var line = text.slice(line_pos1+1, line_pos2); if (!(line === "" || line == "" || line == "{{Webster 1913}}" || (line.indexOf("[[") === 0 && line.indexOf(":") != -1))) break;		line_pos2 = line_pos1;	}

var text_append = text.slice(line_pos2+1); text = text.slice(0, line_pos2) + "\n\n====Translations===="; for (var c1 = 0; c1 < trans_sections.length; c1++) { text += "\n{{trans-top|" + trans_sections[c1] + "}}\n* Portuguese: {{t|pt|}}\n{{trans-mid}}\n{{trans-bottom}}\n"; }	document.editform.wpTextbox1.value = text + text_append; }

jQuery(function ($) {	var pretext = "";	var lang = "";

if (! (window.location.search && window.location.search.split("?")[1])) { return; }	try { parts = window.location.search.split("?")[1].split("&"); } catch (e) { return; }	for (var k = 0; k < parts.length; k++) { pair = parts[k].split("="); if (pair[0] == "plt") { pretext = decodeURIComponent(pair[1].replace(/\+/gi," ")); } else if (pair[0]=="lang") { lang = decodeURIComponent(pair[1].replace(/\+/gi," ")); } else if (pair[0]=="addtrans") { add_translation_tables; }	}	if (pretext.length > 0) { var lines = document.editform.wpTextbox1.value.split("\n"); var langsec; var done = false; var ft = ""; for (var c1 = 0; c1 < lines.length; c1++) { if (!done) { if (/^\[\[[a-z\-]{2,7}:[^\[]*\]\]$/.exec(lines[c1])) {					ft += "\n\n" + pretext + "\n\n";					done = true;				} else if (lines[c1][0] == '=' && lines[c1][1] == '=' && lines[c1][2] != '=') {					langsec = lines[c1].substring(2, lines[c1].length-2);					if (langsec != "English" && langsec != "Translingual" && lang < langsec) {						ft += pretext + "\n\n\n\n";						done = true;					}				}			}			ft += lines[c1];			if (c1 < lines.length-1) ft += '\n';		}		if (!done) {			if (lines.length > 1) ft += "\n\n\n";			ft += pretext;		}		document.editform.wpTextbox1.value = ft;	} });

jQuery(function ($) {	var cat_div = document.createElement("div");	cat_div.id = "searchBody";	cat_div.className = "pBody";	var cat_form = document.createElement("form");	cat_form.id="searchform";	cat_form.action="/w/index.php";	var cat_lolwut = document.createElement("input");	cat_lolwut.type="hidden";	cat_lolwut.value="Special:Search";	cat_lolwut.name="title";	var cat_input = document.createElement("input");	cat_input.id="searchInput";	cat_input.type="search";	cat_input.title="Search Categories";	cat_input.name="search";	cat_input.autocomplete="off";	//cat_input.value="Category:";	var cat_go = document.createElement("input");	cat_go.id="searchGoButton";	cat_go.className="searchButton";	cat_go.type="submit";	cat_go.title="Go";	cat_go.value="Go";	cat_go.name="go";	var cat_search = document.createElement("input");	cat_search.id="mw-searchButton";	cat_search.className="searchButton";	cat_search.type="submit"; cat_search.title="Search"; cat_search.value="Search"; cat_search.name="fulltext"; cat_form.appendChild(cat_lolwut); cat_form.appendChild(cat_input); cat_form.appendChild(cat_go); cat_form.appendChild(cat_search); cat_div.appendChild(cat_form); var main_div = document.getElementById("p-search"); main_div.appendChild(cat_div); var temp_div = document.createElement("div"); temp_div.id = "searchBody"; temp_div.className = "pBody"; var temp_form = document.createElement("form"); temp_form.id="searchform"; temp_form.action="/w/index.php"; var temp_lolwut = document.createElement("input"); temp_lolwut.type="hidden"; temp_lolwut.value="Special:Search"; temp_lolwut.name="title"; var temp_input = document.createElement("input"); temp_input.id="searchInput"; temp_input.type="search"; temp_input.title="Search Templates"; temp_input.name="search"; temp_input.autocomplete="off"; //temp_input.value="Template:"; var temp_go = document.createElement("input"); temp_go.id="searchGoButton"; temp_go.className="searchButton"; temp_go.type="submit"; temp_go.title="Go"; temp_go.value="Go"; temp_go.name="go"; var temp_search = document.createElement("input"); temp_search.id="mw-searchButton"; temp_search.className="searchButton"; temp_search.type="submit"; temp_search.title="Search"; temp_search.value="Search"; temp_search.name="fulltext"; temp_form.appendChild(temp_lolwut); temp_form.appendChild(temp_input); temp_form.appendChild(temp_go); temp_form.appendChild(temp_search); temp_div.appendChild(temp_form); main_div.appendChild(temp_div); });

jQuery(function ($) {	var pos_spans = document.getElementsByClassName("mw-headline");	var edit_spans = document.getElementsByClassName("mw-editsection");

for (var c = 0; c < pos_spans.length; c++) { var id = pos_spans[c].id; if (id.search(/(Noun|Verb|Adjective|Adverb|Preposition|Pronoun|Conjunction|Determiner|Interjection|Proper_noun|Phrase|Prefix|Proverb|Suffix)/) === 0) { var add_trans = document.createElement("span"); add_trans.id = "addTransLink"; add_trans.className = "mw-editsection-addtrans";

var left_bracket = document.createElement("span"); left_bracket.id = "addTransLeftBracket"; left_bracket.className = "mw-editsection-bracket"; left_bracket.innerHTML = "[";

var right_bracket = document.createElement("span"); right_bracket.id = "addTransRightBracket"; right_bracket.className = "mw-editsection-bracket"; right_bracket.innerHTML = "]";

var add_trans_link = document.createElement("a"); add_trans_link.title = "Add translations: " + pos_spans[c].id; add_trans_link.href = edit_spans[c].getElementsByTagName("a")[0].href + "&addtrans=true" + "&summary=/* " + id + " */ Translations."; add_trans_link.className = "mw-editsection-link"; add_trans_link.text = "add trans"; add_trans.appendChild(left_bracket); add_trans.appendChild(add_trans_link); add_trans.appendChild(right_bracket); pos_spans[c].parentNode.appendChild(document.createTextNode(" ")); pos_spans[c].parentNode.appendChild(add_trans); }	} });

jQuery(function ($) {	var senseids = document.getElementsByClassName("senseid");	for (var c = 0; c < senseids.length; c++) {		var text = senseids[c].id		text = text.replace(/_/g, " ")		text = text.split("-")[1]		text = "&lt;" + text + "&gt; "		var span = document.createElement("span");		span.innerHTML = text		span.style = "font-size:x-small;color:green"		senseids[c].insertBefore(span, senseids[c].firstChild)	} });