Jump to content

User:GTrang/common.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by GTrang (talk | contribs) at 21:56, 10 September 2024 (Testing code from User:SD0001/Making user scripts load faster to see whether the "Draftify log" special page will load correctly with that code.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
// Enable caching for resource loads, see [[User:SD0001/Making_user_scripts_load_faster]], @revision 7
if(!/\bnocache=\b/.test(location.href)){let e=mw.config.values,t="text/javascript",r="text/css",n=(n,o,i)=>(n=n.replace(/special:mypage/i,"User:"+e.wgUserName),$.get("https://"+o+"/w/api.php?titles="+n+"&origin=*&format=json&formatversion=2&uselang=content&maxage=86400&smaxage=86400&action=query&prop=revisions|info&rvprop=content&rvlimit=1&inprop=protection").then(e=>{let a=e.query.pages[0];if(!a.missing){if(2!==a.ns&&8!==a.ns&&!a.protection.find(e=>"edit"===e.type&&"sysop"===e.level))return $.Deferred().reject('Refused to load "'+n+'"@'+o+": unprotected page");let l=a.revisions[0].content;if(i&&i!==t||"javascript"!==a.contentmodel){if(i!==r||"css"!==a.contentmodel)return $.Deferred().reject('Refused to load "'+n+'"@'+o+": content type mismatch");mw.loader.addStyleTag(l)}else document.head.appendChild(document.createElement("script")).innerHTML=l}})),o=e.wgServerName,i=e=>{let t=/^(?:(?:https:)?\/\/(.*))?\/w\/index.php/.exec(e),r=/\btitle=([^=?&]*)/.exec(e);return t&&r&&/\baction=raw\b/.test(e)&&/\bctype=/.test(e)?[r[1],t[1]||o]:null};window.importScript=e=>{n(encodeURIComponent(e),o,t)},window.importStyleSheet=e=>{n(encodeURIComponent(e),o,r)};let a=mw.loader.load;mw.loader.load=function(e,t){let r=i(e);r?n(r[0],r[1],t):a.apply(mw.loader,[...arguments])};let l=mw.loader.getScript;mw.loader.getScript=function(e){let r=i(e);return r?n(r[0],r[1],t):l.apply(mw.loader,[...arguments])}}

importScript('User:Jackmcbarn/editProtectedHelper.js'); //Linkback: [[User:Jackmcbarn/editProtectedHelper.js]] Added by Script installer
importScript('User:Enterprisey/delsort.js'); //Linkback: [[User:Enterprisey/delsort.js]] Added by Script installer
importScript('User:MusikAnimal/confirmationRollback.js'); //Linkback: [[User:MusikAnimal/confirmationRollback.js]] Added by Script installer
importScript('User:Enterprisey/cv-revdel.js'); //Linkback: [[User:Enterprisey/cv-revdel.js]] Added by Script installer
importScript('User:Enterprisey/script-installer.js'); //Linkback: [[User:Enterprisey/script-installer.js]] Added by Script installer
importScript('User:MPGuy2824/MoveToDraft.js'); // Backlink: [[User:MPGuy2824/MoveToDraft.js]]
importScript('User:Ahecht/Scripts/pageswap.js'); // Backlink: [[User:Ahecht/Scripts/pageswap.js]]
importScript('User:Awesome_Aasim/xfdvote.js'); // Backlink: [[User:Awesome_Aasim/xfdvote.js]]
importScript('User:Eejit43/scripts/rmtr-helper.js'); // Backlink: [[User:Eejit43/scripts/rmtr-helper.js]]
importScript('User:Eejit43/scripts/afcrc-helper.js'); // Backlink: [[User:Eejit43/scripts/afcrc-helper.js]]