User:PerfektesChaos/js/clickDivertimento/r.js - Wikipedia


Article Images

Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump.
This code will be executed when previewing this page.

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/clickDivertimento/r.js
/// 2019-07-24 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#5887D8CD#
/// @license:CC-by-sa/4.0
/// Documentation:[[w:en:User:PerfektesChaos/js/clickDivertimento]]
///<nowiki>
(function(mw,$){
"use strict";
var Version=1.9,CDV="clickDivertimento",Config={},Prego={};
if(typeof mw.libs[CDV]!=="object"||!mw.libs[CDV]){
mw.libs[CDV]={};}
mw.libs[CDV].type=CDV;
CDV=mw.libs[CDV];
if(typeof CDV.vsn!=="number"){
CDV.vsn=Version;
CDV.signature="ext.gadget."+CDV.type;
CDV.support="User:PerfektesChaos/js/"+CDV.type;
CDV.doc="[[w:en:"+CDV.support+"]]";
Config.pages=["en","de"];
Config.texts={
"^show":{"en":"Click-Divertimento",
"de":"Click-Divertimento"},
"^suffix":{"en":"&#8211; Open links in new browser window",
"de":"&#8211; Links in neuem Browserfenster öffnen"},
"^^large":{"en":"Include more list pages",
"de":"Weitere Seiten mit Listen einschließen"},
"^^leave":{"en":"All external links shall be opened in new browser window",
"de":"Alle externen Links in neuem Browserfenster öffnen"},
"^^mode":{"en":"Create entirely new window",
"de":"Völlig neues Fenster öffnen"},
"^^mode0":{"en":"For all diverted targets",
"de":"Immer, wenn ein Link beeinflusst wird"},
"^^mode1":{"en":"Shared windows for the same tasks",
"de":"Wiederbenutzung für gleiche Aufgaben"},
"^^mode2":{"en":"All in the same different window",
"de":"Alle im selben Zweitfenster"}
};}
function fiat(){
var $hype=$(this),src=$hype.attr("href"),k=src.charCodeAt(0),cond,conds,i,shift;
if(k===35){
$hype=false;
}else{
i=src.indexOf("#");
if(i>0&&src.substr(0,i)===Config.source){
$hype=false;}
if($hype&&k!==47&&src.indexOf("//")<0){
$hype=false;}}
if($hype){
shift=Config.shift;
if(Config.kind===1){
if($hype.hasClass("external")){
if(Config.mode){
shift="WikiExtern";}
}else{
shift=false;}}
if(typeof Config.targets==="object"){
for(k in Config.targets){
conds=Config.targets[k];
for(i=0;i<conds.length;i++){
cond=conds[i];
switch(typeof cond){
case "string":
if(src.indexOf(cond)>=0){
conds=false;}
break;
case "object":
if(cond.test(src)){
conds=false;}
break;}
if(!conds){
break;}}
if(!conds){
shift=k;
break;}}}
if(shift&&!$hype.attr("target")){
$hype.attr("target",shift);}}}
function fit(){
var $hype=$(this);
if(!$hype.attr("target")){
$hype.attr("target",Config.shift);}}
function flyout(){
var suggestion="a.mw-searchSuggest-link",observer,$div;
if(typeof MutationObserver==="function"){
$div=$(".suggestions-results");
if($div.length){
observer=new MutationObserver(function(mutations){
mutations.forEach(function(){
$(suggestion).each(fit);
});
});
observer.observe($div.get(0),{childList:true});}}}
function furnish($area){
var scope,$hypes;
switch(Config.kind){
case 1:
$hypes=$area.find(".external");
break;
case 2:
case 3:
switch(Config.special){
case "Contributions":
$hypes=$area.find("ul,ol");
break;
case "LinkSearch":
$hypes=$area.find(".special");
break;
case "Whatlinkshere":
$hypes=$area.find("#mw-whatlinkshere-list");
break;
case "Recentchanges":
case "Watchlist":
$hypes=$area.find(".mw-changeslist");
break;
default:
$hypes=$area;}
$hypes=$hypes.find("a[href*=\"/\"]");
break;
case 4:
$hypes=$("a[href*=\"/\"]");
Config.kind=3;
break;}
$hypes.each(fiat);
if(Config.kind>1){
scope="#searchform, .searchbox";
if(Config.kind===2&&Config.start==="history"){
scope=scope+", #mw-history-compare";}
$(scope).each(fit);
mw.loader.using(["mediawiki.searchSuggest"],flyout);}}
Config.features=function(){
var pars=[["large","boolean"],["leave","boolean"],["mode","number"]],n=pars.length,i,s,v,vals;
for(i=0;i<n;i++){
v=pars[i];
s=v[0];
if(typeof CDV[s]===v[1]){
this[s]=CDV[s];
}else{
this[s]=false;}}
Prego.lib=mw.libs[Prego.supply];
if(typeof Prego.lib==="object"&&Prego.lib&&typeof Prego.lib.fetch==="function"){
vals=Prego.lib.fetch(CDV.type);
if(vals&&typeof vals==="object"){
for(i=0;i<n;i++){
v=pars[i];
s=v[0];
if(typeof vals[s]===v[1]){
this[s]=vals[s];}}}
}else{
Prego.lib=false;}
if(typeof CDV.targets==="object"&&CDV.targets&&this.mode){
this.targets={};
for(s in CDV.targets){
v=CDV.targets[s];
if(v){
switch(typeof v){
case "string":
v=[v];
break;
case "object":
if(typeof v.length!=="number"){
if(typeof v.ignoreCase==="boolean"){
v=[v];
}else{
v=false;}}
break;
default:
v=false;}
if(v){
this.targets[s]=v;}}}}
};
Config.fire=function(){
var i;
Config.features();
if(Config.learn){
Config.kind=4;
if(Prego.lib){
Prego.form();}
}else{
Config.kind=false;
if(typeof Config.special==="string"){
switch(Config.special){
case "Contributions":
case "LinkSearch":
case "Whatlinkshere":
if(Config.large){
Config.kind=2;}
break;
default:
Config.kind=2;}
}else{
switch(Config.start){
case "edit":
case "submit":
Config.kind=4;
$(".cancelLink").hide();
break;
case "history":
if(Config.large){
Config.kind=2;}
break;
case "view":
if(Config.leave){
Config.kind=1;}
break;}}}
if(Config.kind){
Config.source=window.location.href;
i=Config.source.indexOf("#");
if(i>0){
Config.source=Config.source.substr(0,i);}
switch(Config.mode){
case 1:
Config.shift="_blank";
break;
case 2:
Config.shift="clickDiver";
break;
default:
Config.shift="_blank";}
mw.hook("wikipage.content").add(furnish);}
};
Prego.fire=function(){
var rls,signature;
this.supply="preferencesGadgetOptions";
signature="ext.gadget."+this.supply;
if(!mw.loader.getState(signature)){
rls={};
rls[signature]="loading";
mw.loader.state(rls);
mw.loader.load("https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/"+this.supply+"/r.js&action=raw&bcache=1&maxage=604809&ctype=text/javascript","text/javascript");}
};
Prego.firing=function(){
mw.hook(Prego.supply+".ready").add(Config.fire);
};
Prego.form=function(){
var pages={},poly=[],txt=Config.texts,dialog,i,s;
for(i=0;i<Config.pages.length;i++){
s=Config.pages[i];
pages[s]="//"+s+".wikipedia.org/wiki/"+CDV.support;}
for(i=0;i<3;i++){
poly.push({val:i,show:txt["^^mode"+i]});}
dialog={script:CDV.type,show:txt["^show"],support:pages,suffix:txt["^suffix"],opts:[{signature:"large",type:"checkbox",show:txt["^^large"],val:Config.large
},{signature:"leave",type:"checkbox",show:txt["^^leave"],val:Config.leave
},{signature:"mode",type:"radio",show:txt["^^mode"],val:Config.mode,poly:poly}]};
Prego.lib.form(dialog);
};
CDV.fire=function(){
var env,launch,rls;
if(mw.loader.getState(CDV.signature)!=="ready"){
rls={};
rls[CDV.signature]="ready";
mw.loader.state(rls);
env=mw.config.get(["wgAction","wgCanonicalSpecialPageName","wgNamespaceNumber"]);
launch=true;
Config.learn=false;
if(env.wgNamespaceNumber===-1){
Config.special=env.wgCanonicalSpecialPageName;
switch(Config.special){
case "Blankpage":
case "Gadgets":
Config.learn=true;
break;
case "Contributions":
case "EditWatchlist":
case "LinkSearch":
case "Recentchanges":
case "Watchlist":
case "Whatlinkshere":
break;
default:
launch=false;}
}else{
Config.start=env.wgAction;}
if(launch){
Prego.fire();
mw.loader.using(["user","user.options"],Prego.firing);}}
};
CDV.fire();
}(window.mediaWiki,window.jQuery));
/// EOF</nowiki>clickDivertimento/r.js