User:Manishearth/scriptlinks.js

//Test stuff: // User:Manishearth boom // boom // http://www.wikia.com/blooper/testlink /* Boomdeyada */ /* Boomdeyada BOOM importScript("boom.js") importScript('boom.js') function scriptLinks(className){ pre = document.querySelectorAll(".source-javascript"); for(i = 0; i < pre.length; i++) { par = pre[i].querySelectorAll("span." + className); for(j = 0; j < par.length; j++) { par[j].innerHTML=par[j].innerHTML.replace(/\[\[([^\]\|]*)\]\]/g,"$1"); par[j].innerHTML=par[j].innerHTML.replace(/\[\[([^\]\|]*)[\|]?([^\]]*)\]\]/g,"$2"); par[j].innerHTML=par[j].innerHTML.replace(/\[(http[s]?:[^\]\s]*)\]/g,"$1"); par[j].innerHTML=par[j].innerHTML.replace(/\[(http[s]?:[^\]\s]*)\s([^\]]*)\]/g,"$2"); par[j].innerHTML=par[j].innerHTML.replace(/([^\"\>][\s]?)(http[s]?:\/\/[^\s]*)/g,"$2");		}	} } $(function{

scriptLinks("co1"); scriptLinks("co2"); scriptLinks("coMULTI"); importScript_links;

});

//Taken from User:AoV2/importScript_links function importScript_links{ pre = document.querySelectorAll(".source-javascript"); for(i = 0; i < pre.length; i++) { par = pre[i].querySelectorAll("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;			var h= s.innerHTML + "";			var h2=h+"";			var h3=h2+""			var h4=h3+"";			var q;			var quo;			if(s.className != "st0") continue;			else if(h.match(/"([^\"']+)\"/)) {				q = /\"([^\"']*)\"/g;				quo='\"'				p = encodeURIComponent(h3.replace(q, "$1").replace(/[_\s]+/g, "_")).replace(/%2F/g, "/");				s.innerHTML = quo + '' + h4.replace(q, "$1") + '' + quo;			}else if(h2.match(/'([^'\"]+)\'/)) { 				q = /'([^'\"]*)'/g;				quo="\'"				p = encodeURIComponent(h3.replace(q, "$1").replace(/[_\s]+/g, "_")).replace(/%2F/g, "/");				s.innerHTML = quo + '' + h4.replace(q, "$1") + '' + quo; }else{ continue;} }	} }