Jump to content
Wikipedia The Free Encyclopedia

User:PerfektesChaos/js/clickDivertimento/r.js

From Wikipedia, the free encyclopedia
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.
This user script seems to have a documentation page at User:PerfektesChaos/js/clickDivertimento/r.
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";
 varVersion=1.9,CDV="clickDivertimento",Config={},Prego={};
 if(typeofmw.libs[CDV]!=="object"||!mw.libs[CDV]){
 mw.libs[CDV]={};}
 mw.libs[CDV].type=CDV;
 CDV=mw.libs[CDV];
 if(typeofCDV.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"}
 };}
 functionfiat(){
 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(typeofConfig.targets==="object"){
 for(kinConfig.targets){
 conds=Config.targets[k];
 for(i=0;i<conds.length;i++){
 cond=conds[i];
 switch(typeofcond){
 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);}}}
 functionfit(){
 var$hype=$(this);
 if(!$hype.attr("target")){
 $hype.attr("target",Config.shift);}}
 functionflyout(){
 varsuggestion="a.mw-searchSuggest-link",observer,$div;
 if(typeofMutationObserver==="function"){
 $div=$(".suggestions-results");
 if($div.length){
 observer=newMutationObserver(function(mutations){
 mutations.forEach(function(){
 $(suggestion).each(fit);
 });
 });
 observer.observe($div.get(0),{childList:true});}}}
 functionfurnish($area){
 varscope,$hypes;
 switch(Config.kind){
 case1:
 $hypes=$area.find(".external");
 break;
 case2:
 case3:
 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;
 case4:
 $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(){
 varpars=[["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(typeofCDV[s]===v[1]){
 this[s]=CDV[s];
 }else{
 this[s]=false;}}
 Prego.lib=mw.libs[Prego.supply];
 if(typeofPrego.lib==="object"&&Prego.lib&&typeofPrego.lib.fetch==="function"){
 vals=Prego.lib.fetch(CDV.type);
 if(vals&&typeofvals==="object"){
 for(i=0;i<n;i++){
 v=pars[i];
 s=v[0];
 if(typeofvals[s]===v[1]){
 this[s]=vals[s];}}}
 }else{
 Prego.lib=false;}
 if(typeofCDV.targets==="object"&&CDV.targets&&this.mode){
 this.targets={};
 for(sinCDV.targets){
 v=CDV.targets[s];
 if(v){
 switch(typeofv){
 case"string":
 v=[v];
 break;
 case"object":
 if(typeofv.length!=="number"){
 if(typeofv.ignoreCase==="boolean"){
 v=[v];
 }else{
 v=false;}}
 break;
 default:
 v=false;}
 if(v){
 this.targets[s]=v;}}}}
 };
 Config.fire=function(){
 vari;
 Config.features();
 if(Config.learn){
 Config.kind=4;
 if(Prego.lib){
 Prego.form();}
 }else{
 Config.kind=false;
 if(typeofConfig.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){
 case1:
 Config.shift="_blank";
 break;
 case2:
 Config.shift="clickDiver";
 break;
 default:
 Config.shift="_blank";}
 mw.hook("wikipage.content").add(furnish);}
 };
 Prego.fire=function(){
 varrls,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(){
 varpages={},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(){
 varenv,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

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