Jump to content

User:PerfektesChaos/js/externalLinkProblem/raw/r.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/// User:PerfektesChaos/js/externalLinkProblem/raw/r.js
/// 2018-08-24 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#3D869E3C#
/// @license GPL [//www.mediawiki.org/w/COPYING](+GFDL,LGPL,CC-BY-SA)
///<nowiki>
(function(mw){
"use strict";
var Version=2.8,ELP="externalLinkProblem",Sub="raw";
if(typeof mw.libs[ELP]!=="object"||!mw.libs[ELP]){
mw.libs[ELP]={};}
mw.libs[ELP].type=ELP;
ELP=mw.libs[ELP];
if(typeof ELP[Sub]!=="object"){
ELP[Sub]={};}
ELP[Sub].vsn=Version;
if(typeof ELP.talk!=="object"){
ELP.talk={};}
function facilitated(){
var rls,signature,sub;
if(typeof ELP.signature==="string"){
sub="/"+Sub;
signature=ELP.signature+sub;
if(mw.loader.getState(signature)!=="ready"){
rls={};
rls[signature]="ready";
mw.loader.state(rls);
mw.hook(ELP.type+sub+".ready").fire();}}}
function fact(assign,assigned){
var r=assigned,got,i,p,sign,stuff,v;
if(assign){
p=assign.split(" ");
if(typeof ELP.raw.regExps!=="object"){
ELP.raw.regExps={cit:"(-?cit=[0-9A-Za-z]+)",link:"(proto)",listed:"(sbl)",less:"(-)",mode:"([3-9][0-9][0-9])",other:"\\+([0-9]+(?:,[0-9]+)*)",since:"(2[01][0-9][0-9])",wba:"(-?wba=[12][09][0-9]+)"
};
for(sign in ELP.raw.regExps){
stuff="^ *"+ELP.raw.regExps[sign]+" *$";
ELP.raw.regExps[sign]=new RegExp(stuff);}}
for(i=0;i<p.length;i++){
stuff=p[i];
for(sign in ELP.raw.regExps){
got=ELP.raw.regExps[sign].exec(stuff);
if(got){
v=got[1];
if(v.charCodeAt(0)===45){
v=v.substr(1);
r.less=true;}
switch(sign){
case "cit":
v=v.substr(4);
break;
case "less":
case "link":
case "listed":
v=true;
break;
case "mode":
v=parseInt(v,10);
break;
case "other":
v=v.split(",");
break;
case "since":
break;
case "wba":
v=v.substr(4);
if(v.length<10){
v=false;}
break;}
r[sign]=v;
break;}}}}
return r;}
function factory(at){
var r=-1,s=ELP.talk.story,t=ELP.project.template,got,i,k,learnt,n,p,ul,v;
i=s.indexOf("{{"+t.seek,at);
if(i>=0){
n=t.seek.length+i+2;
k=s.charCodeAt(n);
if(k===124||k===10){
r=s.indexOf("\n}}",n);
if(r>0){
s=s.substring(n,r);
p=s.split("|");
n=p.length;
if(n>1){
if(typeof ELP.raw.reEntry!=="object"){
ELP.raw.reEntry="^\\s*[0-9]+\\s*=\\s*(?:([^:/\n]+) +)?((?:https?|ftps?|mailto):\\S+)(?:\\s+([^ \n}].+)?|\\s*(?:\\}\\})?)$";
ELP.raw.reEntry=new RegExp(ELP.raw.reEntry);
ELP.raw.reRun="^ *"+t.sign+" *= *([-0-9/A-Z.a-z:]+)(?:[ \n]| *}})";
ELP.raw.reRun=new RegExp(ELP.raw.reRun);}
for(i=1;i<n;i++){
got=ELP.raw.reRun.exec(p[i]+" ");
if(got){
s=got[1];
if(s>=t.stamp){
r=-9;
break;}}}
if(r===-9){
ul=[];
for(i=0;i<n;i++){
got=ELP.raw.reEntry.exec(p[i]+" ");
if(got){
s=got[2].replace(/</g,"%3C");
learnt=(got[3]?true:false);
v=fact(got[1],{url:s,learnt:learnt});
ul.push(v);}}
if(ul.length){
r=ul;}}}
}else{
r=n;}
}else{
r=n;}
}else if(!i){
r=-8;}
return r;}
function feed(){
var i=0,p;
ELP.problems=null;
while(i>=0){
p=factory(i);
switch(typeof p){
case "number":
i=p;
break;
case "object":
ELP.problems=p;
i=-2;
break;
default:
i=-3;}}
if(typeof ELP.project.raw==="object"&&ELP.project.raw){
p=ELP.project.raw;
if(typeof p.skip==="string"&&ELP.talk.story.indexOf(p.skip)>0){
ELP.talk.last=true;}
if(typeof p.old==="object"&&p.old&&typeof p.old.length==="number"){
for(i=0;i<p.old.length;i++){
if(ELP.talk.story.indexOf(p.old[i])>=0){
ELP.talk.last=true;}}}}
if(ELP.raw.follow){
ELP.raw.follow();}}
function fetched(arrived){
var q;
if(typeof arrived==="object"&&typeof arrived.query==="object"&&typeof arrived.query.pages==="object"){
if(!ELP.talk.id&&typeof arrived.query.pageids==="object"){
ELP.talk.id=arrived.query.pageids[0];}
q=arrived.query.pages[ELP.talk.id];
if(typeof q==="object"&&typeof q.revisions==="object"){
q=q.revisions[0];
if(typeof q==="object"&&typeof q["*"]==="string"){
ELP.talk.story=q["*"];
feed();}}}}
function fire(){
var q=new mw.Api(),w={action:"query","continue":"",indexpageids:true,prop:"revisions",rvprop:"content"
};
if(!ELP.talk.id){
if(ELP.talk.leader){
if(!ELP.spot){
ELP.spot=mw.config.get("wgTitle");}
if(typeof ELP.nsubject==="number"){
if(!ELP.envNS){
ELP.envNS=mw.config.get("wgFormattedNamespaces");}
ELP.sibling=ELP.envNS[ELP.nsubject+1];}
}else{
ELP.talk.id=mw.config.get("wgArticleId");}}
if(ELP.talk.id){
w.pageids=ELP.talk.id;
}else if(ELP.sibling&&ELP.spot){
ELP.talk.spot=ELP.sibling+":"+ELP.spot;
w.titles=ELP.talk.spot.replace(/\s/g,"_");
}else{
w=false;}
if(w){
q.get(w).done(fetched);}}
ELP[Sub].fire=function(action){
facilitated();
if(typeof ELP.project==="object"&&ELP.project&&typeof ELP.talk==="object"&&ELP.talk){
ELP.raw.follow=action;
mw.loader.using(["mediawiki.api"],fire);}
};
function first(){
facilitated();}
first();
}(window.mediaWiki,window.jQuery));
/// EOF</nowiki>externalLinkProblem/raw/r.js