🇮🇷 Iran Proxy | https://www.wikipedia.org/wiki/User:Toadspike/common.js
Jump to content

User:Toadspike/common.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.
// Enable caching for resource loads, see [[User:SD0001/Making_user_scripts_load_faster]], @revision 8
if(!/\bnocache=\b/.test(location.href)){let e=mw.config.values,t="text/javascript",o="text/css",n=(n,r,i)=>(n=n.replace(/special:mypage/i,"User:"+e.wgUserName),$.get("https://"+r+"/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+'"@'+r+": unprotected page");let e=a.revisions[0].content;if(i&&i!==t||"javascript"!==a.contentmodel){if(i!==o||"css"!==a.contentmodel)return $.Deferred().reject('Refused to load "'+n+'"@'+r+": content type mismatch");mw.loader.addStyleTag(e)}else{let t=document.createElement("script");t.innerHTML=e,document.head.appendChild(t)}}}))),r=e.wgServerName,i=e=>{let t=/^(?:(?:https:)?\/\/(.*))?\/w\/index.php/.exec(e),o=/\btitle=([^=?&]*)/.exec(e);return t&&o&&/\baction=raw\b/.test(e)&&/\bctype=/.test(e)?[o[1],t[1]||r]:null};window.importScript=e=>{n(encodeURIComponent(e),r,t)},window.importStyleSheet=e=>{n(encodeURIComponent(e),r,o)};let a=mw.loader.load;mw.loader.load=function(e,t){let o=i(e);o?n(o[0],o[1],t):a.apply(mw.loader,[...arguments])};let l=mw.loader.getScript;mw.loader.getScript=function(e){let o=i(e);return o?n(o[0],o[1],t):l.apply(mw.loader,[...arguments])}}

// (stuff from here on out shamelessly ripped from asilvering) if you want to conditionally load scripts depending on namespace or page name like I do below, you need to add this to your common.js
const ns = mw.config.get('wgNamespaceNumber');
const page = mw.config.get('wgPageName');

// SPI
if (page.startsWith('Wikipedia:Sockpuppet_investigations')) {
	importScript('User:GeneralNotability/spihelper.js'); // Backlink: [[User:GeneralNotability/spihelper.js]]
	importScript('User:Daniel Quinlan/Scripts/SockTags.js'); // Backlink: [[User:Daniel Quinlan/Scripts/SockTags.js]]
	importScript('User:Daniel Quinlan/Scripts/SockDecay.js'); // Backlink: [[User:Daniel Quinlan/Scripts/SockDecay.js]]
}
if (page.startsWith('Category:Suspected Wikipedia sockpuppets')) {
	importScript('User:Daniel Quinlan/Scripts/SockDecay.js'); // Backlink: [[User:Daniel Quinlan/Scripts/SockDecay.js]]
}

// RM/TR
if (page.startsWith('Wikipedia:Requested_moves')) {
	importScript('User:Eejit43/scripts/rmtr-helper.js'); // Backlink: [[User:Eejit43/scripts/rmtr-helper.js]]
}

// AfD
if (page.startsWith('Wikipedia:Articles_for_deletion')) {
	importScript('User:DannyS712/SATG.js'); // Backlink: [[User:DannyS712/SATG.js]] (source assessment table generator)
	importScript('User:Enterprisey/delsort.js'); // Backlink: [[User:Enterprisey/delsort.js]]
}

// user talk scripts 
if (ns === 3) {
	importScript('User:Novem Linguae/Scripts/UserTalkErasedSectionsDetector.js'); // Backlink: [[User:Novem Linguae/Scripts/UserTalkErasedSectionsDetector.js]]
	importScript('User:Novem Linguae/Scripts/UnblockReview.js'); // Backlink: [[User:Novem Linguae/Scripts/UnblockReview.js]]
}

// both talks
if (ns === 1 || ns === 3) {
	importScript('User:Elli/OneClickArchiver.js'); // Backlink: [[User:Elli/OneClickArchiver.js]]
}

// discussion closing 
if (ns === 1 || ns === 4 || ns === 5) {
	importScript('User:BilledMammal/MovePlus.js'); // Backlink: [[User:BilledMammal/MovePlus.js]]
	importScript('User:DaxServer/DiscussionCloser.js'); // Backlink: [[User:DaxServer/DiscussionCloser.js]]
	importScript('User:Novem Linguae/Scripts/VoteCounter.js'); // Backlink: [[User:Novem Linguae/Scripts/VoteCounter.js]]
}

// noms viewer
if (page.startsWith('Wikipedia:Featured') || page.startsWith('Wikipedia:Peer_review')) {
	importScript('User:Gary/nominations viewer.js'); // [[Wikipedia:Nominations Viewer]]
}

// mainspace only
if (ns === 0) {
	importScript( 'User:MPGuy2824/MoveToDraft.js' ); // Backlink: [[User:MPGuy2824/MoveToDraft.js]]
	importScript( 'User:Sohom Datta/fastreview.js' );// [[User:Sohom Datta/fastreview.js]]
	//importScript('User:Nardog/RefRenamer.js'); // Backlink: [[User:Nardog/RefRenamer.js]]
	importScript('User:Novem_Linguae/Scripts/CiteHighlighter.js'); // Backlink: [[User:Novem_Linguae/Scripts/CiteHighlighter.js]]
	//importScript('User:Novem Linguae/Scripts/DetectSNG.js'); // Backlink: [[User:Novem Linguae/Scripts/DetectSNG.js]]
	importScript('User:Shubinator/DYKcheck.js'); // Backlink: [[User:Shubinator/DYKcheck.js]]
	//importScript('User:Novem Linguae/Scripts/NPPLinks.js'); // Backlink: [[User:Novem Linguae/Scripts/NPPLinks.js]]
	importScript( 'User:Enterprisey/cv-revdel.js' ); // Backlink: [[User:Enterprisey/cv-revdel.js]]
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Ahecht/Scripts/massmove.js&action=raw&ctype=text/javascript' ); //[[User:Ahecht/Scripts/massmove.js]]
	importScript('User:Rusalkii/previewRedirectContext.js'); //Backlink: [[User:Rusalkii/previewRedirectContext.js]]
}

// mainspace and talk
if (ns === 0 || ns === 1) {
	importScript('User:Evad37/rater.js'); // Backlink: [[User:Evad37/rater.js]]
}

// mainspace and userspace
if (ns === 0 || ns === 2) {
	importScript('User:Novem Linguae/Scripts/WatchlistAFD.js'); // Backlink: [[User:Novem Linguae/Scripts/WatchlistAFD.js]]
}

// individual DYK
if (page.startsWith('Template:Did_you_know_nominations/')) {
	importScript('User:DannyS712/DYK_claim.js'); // Backlink: [[User:DannyS712/DYK_claim.js]]
}

// GAN/GAR
if (page.startsWith('Wikipedia:Good_article_reassessment')) {
	importScript('User:Novem Linguae/Scripts/GANReviewTool.js'); // Backlink: [[User:Novem Linguae/Scripts/GANReviewTool.js]]
}

//PERM
if (page.startsWith('Wikipedia:Requests_for_permissions')) {
	importScript('User:MusikAnimal/userRightsManager.js'); // Backlink: [[User:MusikAnimal/userRightsManager.js]]
}

//Projectspace
if (ns === 4 ) {
	importScript('User:Daniel Quinlan/Scripts/Headway.js'); // Backlink: [[User:Daniel Quinlan/Scripts/Headway.js]]
}

//currently unused
//importScript('User:Ohconfucius/script/MOSNUM dates.js'); // Backlink: [[User:Ohconfucius/script/MOSNUM dates.js]]
//importScript('User:Theleekycauldron/DYK_promoter.js'); // Backlink: [[User:Theleekycauldron/DYK_promoter.js]]
//importScript('User:Fran Rogers/dimorphism.js'); // Backlink: [[User:Fran Rogers/dimorphism.js]]
//importScript('User:SD0001/W-Ping.js'); // Backlink: [[User:SD0001/W-Ping.js]]
//importScript( 'User:SuperHamster/CiteUnseen.js' ); // Backlink: [[User:SuperHamster/CiteUnseen.js]]
//importScript('User:Scaledish/Scripts/404.js'); // Backlink: [[User:Scaledish/Scripts/404.js]]

//the rest of 'em (all namespaces)
importScript('User:Nardog/MoveHistory.js'); // Backlink: [[User:Nardog/MoveHistory.js]]
importScript('User:Daniel Quinlan/Scripts/Blame.js'); // Backlink: [[User:Daniel Quinlan/Scripts/Blame.js]]
importScript('User:Ahecht/Scripts/pageswap.js'); // Backlink: [[User:Ahecht/Scripts/pageswap.js]]
importScript('User:GeneralNotability/mark-locked.js'); // Backlink: [[User:GeneralNotability/mark-locked.js]]
importScript('User:BrandonXLF/QuickEdit.js'); // Backlink: [[User:BrandonXLF/QuickEdit.js]]
importScript('User:Novem Linguae/Scripts/VisualEditorEverywhere.js'); // Backlink: [[User:Novem Linguae/Scripts/VisualEditorEverywhere.js]]
importScript('User:DreamRimmer/DeletedMetaData.js'); // Backlink: [[User:DreamRimmer/DeletedMetaData.js]]
importScript('User:SD0001/DYK-helper.js'); // Backlink: [[User:SD0001/DYK-helper.js]]
importScript('User:Daniel Quinlan/Scripts/Unfiltered.js'); // Backlink: [[User:Daniel Quinlan/Scripts/UnfilteredAlpha.js]]
importScript('User:Bradv/Scripts/ExpandDiffs.js'); // Backlink: [[User:Bradv/Scripts/ExpandDiffs.js]]
importScript('User:Daniel Quinlan/Scripts/UserHighlighter.js'); // Backlink: [[User:Daniel Quinlan/Scripts/UserHighlighter.js]]