User:Msh210/hyphenate.js

//many thanks to w:User:Splarka for help with this script function hyphenate { hyphenated=wgPageName.replace(/_/g,"-"); apiurl=wgServer; apiurl+="/w/api.php?action=query&list=logevents&letype=delete&lelimit=1&prop=info&format=json&callback=existence"; apiurl+="&titles="+hyphenated+"&letitle="+hyphenated; mw.loader.load(apiurl); } function existence(param) { en=document.getElementById("English"); n=document.getElementById("Noun"); if (!en || !n) return; hyphenated=wgPageName.replace(/_/g,"-"); autoedit="s{{subst:new_en_adj_attr_bot|" + wgTitle + "|" + hyphenated + " ~g;"; url=wgServer+"/wiki/"+hyphenated+"?action=edit&autoedit="+autoedit;//+"&autoclick=wpDiff"; a=document.createElement('a'); a.setAttribute('href',url); a.appendChild(document.createTextNode(hyphenated)); a.setAttribute('style','color:#22cc00');//match WT:ACCEL // goodforcreation=1; if (!(param['query']['pages']['-1'])) goodforcreation=0; // if (param['query']['logevents'][0]) goodforcreation=0; if (goodforcreation) { en.parentNode.parentNode.insertBefore(a,en.parentNode.nextSibling.nextSibling.nextSibling);//right after the h2; FF-specific? } } if (wgNamespaceNumber==0 && wgAction=="view" && wgPageName.indexOf("_")!=-1) addOnloadHook(hyphenate);

function ligate { ligated=wgPageName.replace(/אל/g,"ﭏ"); apiurl=wgServer; apiurl+="/w/api.php?action=query&list=logevents&letype=delete&lelimit=1&prop=info&format=json&callback=existence2"; apiurl+="&titles="+ligated+"&letitle="+ligated; mw.loader.load(apiurl); } function existence2(param) { he=document.getElementById("Hebrew"); if (!he) return; ligated=wgPageName.replace(/אל/g,"ﭏ"); autoedit="s#redirect " + wgTitle + " typographic variant~g;"; url=wgServer+"/wiki/"+ligated+"?action=edit&redlink=1&autoedit="+autoedit; a=document.createElement('a'); a.setAttribute('href',url); a.appendChild(document.createTextNode(ligated)); a.setAttribute('style','color:#22cc00');//match WT:ACCEL // goodforcreation=1; if (!(param['query']['pages']['-1'])) goodforcreation=0; // if (param['query']['logevents'][0]) goodforcreation=0; if (goodforcreation) { he.parentNode.parentNode.insertBefore(a,he.parentNode.nextSibling.nextSibling); } } if (wgNamespaceNumber==0 && wgAction=="view" && wgPageName.indexOf("אל")!=-1) addOnloadHook(ligate);