User:Manishearth/scriptlinks.js: Difference between revisions

Content deleted Content added
No edit summary
maintenance: more info Uncaught ReferenceError: getElementsByClassName is not defined
 
(20 intermediate revisions by 3 users not shown)
Line 10:
importScript('boom.js')
function scriptLinks(className){
pre = getElementsByClassNamedocument.querySelectorAll(document, "pre", ".source-javascript");
for(i = 0; i < pre.length; i++) {
par = getElementsByClassName(pre[i], .querySelectorAll("span.", + className);
for(j = 0; j < par.length; j++) {
par[j].innerHTML=par[j].innerHTML.replace(/\[\[([^\]\|]*)\]\]/g,"<a href='"+mw.config.get('wgServer')+mw.config.get('wgArticlePath')+"/wiki/$1\'>$1</a>");
par[j].innerHTML=par[j].innerHTML.replace(/\[\[([^\]\|]*)[\|]?([^\]]*)\]\]/g,"<a href='"+mw.config.get('wgServer')+mw.config.get('wgArticlePath')+"/wiki/$1'>$2</a>");
par[j].innerHTML=par[j].innerHTML.replace(/\[(http[s]?:\/\/[^\]\s]*)\]/g,"<a href=\'$1\'>$1</a>");
par[j].innerHTML=par[j].innerHTML.replace(/\[(http[s]?:\/\[^\]\s]*)[\s]?([^\]]*)\]/g,"<a href=\'$1\'>$2</a>");
//par[j].innerHTML=par[j].innerHTML.replace(/([^\"\>][\s]?+)(http[s]?:\/\/[^\s]*)/g,"<a href=\'$12\'>$12</a>");
}
}
}
addOnloadHook$(function(){
 
scriptLinks("co1");
Line 33:
//Taken from [[User:AoV2/importScript_links]]
function importScript_links(){
pre = getElementsByClassNamedocument.querySelectorAll(document, "pre", ".source-javascript");
for(i = 0; i < pre.length; i++) {
par = getElementsByClassName(pre[i], .querySelectorAll("span", ".br0");
for(j = 0; j < par.length; j++) {
if(par[j].innerHTML != "(") continue;
Line 42:
if(!o.data.match(/\bimportScript\s*$/)) continue;
s = par[j].nextSibling;
var h= s.innerHTML + "";
var h2=h+"";
var h3=h2+""
var h4=h3+"";
var q;
var quo;
if(s.className != "st0") continue;
else if(s.innerHTMLh.match(/^"([^\"']+)\"$/)) q = "\"";{
else q if= /\"(s.innerHTML.match(/^'[^\"']+'$/*)) q = "\'"/g;
quo='\"'
else continue;
p = encodeURIComponent(s.childNodes[0].datah3.replace(q, "", "g$1").replace(/[_\s]+/g, "_")).replace(/%2F/g, "/");
s.innerHTML = qquo + '<a href=\"' + mw.config.get('wgArticlePath').replace("$1", p) + '\">' + s.innerHTMLh4.replace(q, "", "g$1") + '</a>' + qquo;
}else if(h2.match(/'([^'\"]+)\'/)) {
}
q = /'([^'\"]*)'/g;
quo="\'"
p = encodeURIComponent(h3.replace(q, "$1").replace(/[_\s]+/g, "_")).replace(/%2F/g, "/");
s.innerHTML = quo + '<a href=\"' + mw.config.get('wgArticlePath').replace("$1", p) + '\">' + h4.replace(q, "$1") + '</a>' + quo;
}else{ continue;}
}
}
}
}