Jump to content
Wikipedia The Free Encyclopedia

User:AoV2/importScript links

From Wikipedia, the free encyclopedia

This provides a link to the source page of an importScript(), for ease of navigation. Needless to say it only works if the parameter is a string literal. ―AoV2 11:11, 27 March 2010 (UTC)

functionimportScript_links(){
pre=getElementsByClassName(document,"pre","source-javascript");
for(i=0;i<pre.length;i++){
par=getElementsByClassName(pre[i],"span","br0");
for(j=0;j<par.length;j++){
if(par[j].innerHTML!="(")continue;
o=par[j].previousSibling;
if(o.nodeType!=3)continue;
if(!o.data.match(/\bimportScript\s*$/))continue;
s=par[j].nextSibling;
if(s.className!="st0")continue;
elseif(s.innerHTML.match(/^"[^"]+"$/))q="\"";
elseif(s.innerHTML.match(/^'[^']+'$/))q="\'";
elsecontinue;
p=encodeURIComponent(s.childNodes[0].data.replace(q,"","g").replace(/[_\s]+/g,"_")).replace(/%2F/g,"/");
s.innerHTML=q+'<a href="'+wgArticlePath.replace("1ドル",p)+'">'+s.innerHTML.replace(q,"","g")+'</a>'+q;
}
}
}
addOnloadHook(importScript_links);

AltStyle によって変換されたページ (->オリジナル) /