Jump to content

User:Chlod/common.js

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
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.
// === ADDITIONAL NOTES ===
// As a JavaScript developer, I might write code here that isn"t
// properly documented. If you want to know what a specific part
// of my common.js does, please reach out to my on my talk page.
//
// Thank you! Have a nice day.

// Override the import script function to use mw.loader (not using the function
// name itself to avoid AWB replaces or search indexes)
window[atob("aW1wb3J0U2NyaXB0")] = function (page, oldid) {
	const url = new URL("/w/index.php", window.location.href);
	url.searchParams.set("title", page);
	if (oldid != null)
		url.searchParams.set("oldid", oldid);
	url.searchParams.set("action", "raw");
	url.searchParams.set("ctype", "text/javascript");
	// The following likely won"t pass any userscript usage regexes, so userscript
	// imports won"t be counted twice (only the import script version will be counted).
	mw.loader.load(url.toString());
};

// Enable caching for resource loads, see [[User:SD0001/Making_user_scripts_load_faster]], @revision 5
if(!/\bnocache=\b/.test(location.href)){var e=function(e,t,r){return e=e.replace(/special:mypage/i,"User:"+mw.config.get("wgUserName")),$.get("https://"+t+"/w/api.php?titles="+e+"&origin=*&format=json&formatversion=2&uselang=content&maxage=86400&smaxage=86400&action=query&prop=revisions|info&rvprop=content&rvlimit=1").then((function(n){var o=n.query.pages[0];if(!o.missing){var a=o.revisions[0].content;if(r&&"text/javascript"!==r||"javascript"!==o.contentmodel){if("text/css"!==r||"css"!==o.contentmodel)return $.Deferred().reject('Refused to load "'+e+'"@'+t+": content type mismatch");mw.loader.addStyleTag(a)}else{if(2!==o.ns&&8!==o.ns)return $.Deferred().reject('Refused to load "'+e+'"@'+t+": outside User and MediaWiki space");var i=document.createElement("script");i.innerHTML=a,document.head.appendChild(i)}}}))},t=function(e){var 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]||mw.config.get("wgServerName")]:null};window.importScript=function(t){e(encodeURIComponent(t),mw.config.get("wgServerName"),"text/javascript")},window.importStyleSheet=function(t){e(encodeURIComponent(t),mw.config.get("wgServerName"),"text/css")};var r=mw.loader.load;mw.loader.load=function(n,o){var a=t(n);a?e(a[0],a[1],o):r.apply(mw.loader,Array.prototype.slice.call(arguments))};var n=mw.loader.getScript;mw.loader.getScript=function(r){var o=t(r);return o?e(o[0],o[1],"text/javascript"):n.apply(mw.loader,Array.prototype.slice.call(arguments))}}

// === EVERYTHING BELOW THIS POINT WAS WRITTEN BY "Chlod" ===
// I take responsibility for whatever is written below this section, including sublinks.

// mw.loader.load( '/w/index.php?title=User:Chlod/Scripts/Deputy.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:Chlod/Scripts/Deputy.js]]
if ( window.location.search.indexOf( '?deputy-isolation=1' ) !== -1 ) {
	mw.hook( 'infringementAssistant.preload' ).add( function() {
		window.InfringementAssistant.wikiConfig.ia.rootPage.set(new mw.Title("User:Chlod/Scripts/Deputy/tests/Problems"));
	} );
	mw.hook( 'deputy.preload' ).add( function () {
		// Replace resource root to load local development assets
		window.deputy.resourceRoot = { type: "url", url: new URL( "http://localhost:45000/" ) };
		window.deputy.getWikiConfig().then( function (wikiConfig) {
			// Override root pages for testing
			wikiConfig.cci.rootPage.set(new mw.Title( 'User:Chlod/Scripts/Deputy/tests' ));
			wikiConfig.ia.rootPage.set(new mw.Title("User:Chlod/Scripts/Deputy/tests/Problems"));
		} );
	} );
}

// importScript("User:Chlod/Scripts/RCP-CV Quicklink.js"); // [[User:Chlod/Scripts/RCP-CV Quicklink.js]]
importScript("User:Chlod/Scripts/UserHighlighter.js"); // [[User:Chlod/Scripts/UserHighlighter.js]]
importScript("User:Chlod/Scripts/DirectPDFDownload.js"); // [[User:Chlod/Scripts/DirectPDFDownload.js]]
importScript("User:Chlod/Scripts/GlobalUserToolbox.js"); // [[User:Chlod/Scripts/GlobalUserToolbox.js]]
importScript("User:Chlod/Scripts/ReferenceDeselector.js"); // [[User:Chlod/Scripts/ReferenceDeselector.js]]
importScript("User:Chlod/Scripts/NewTabMMVDetails.js"); // [[User:Chlod/Scripts/NewTabMMVDetails.js]]
importScript("User:Chlod/Scripts/StormCountTally.js"); // [[User:Chlod/Scripts/StormCountTally.js]]
importScript("User:Chlod/Scripts/FoldArchives.js"); // [[User:Chlod/Scripts/FoldArchives.js]]
importScript("User:Chlod/Scripts/Deputy.js"); // [[User:Chlod/Scripts/Deputy.js]]
importScript("User:Chlod/Scripts/Coordinator.js"); // [[User:Chlod/Scripts/Coordinator.js]]
importScript("User:Chlod/Scripts/WordCount.js"); // Backlink: [[User:Chlod/Scripts/WordCount.js]]
// Loaded globally.
// importScript("User:Chlod/Scripts/GoToTitle.js"); // [[User:Chlod/Scripts/GoToTitle.js]]
// importScript("User:Chlod/Scripts/SectionLink.js"); // [[User:Chlod/Scripts/SectionLink.js]]

// importScript("User:Chlod/sandbox.js");
mw.loader.load("http://localhost:45990/Sandboxifier.js");

// === STYLESHEETS BY OTHER USERS ===

// not working
// if (mw.config.get("skin") !== "vector-2022")
//	importStylesheet("User:BrandonXLF/FloatHead.css"); // [[User:BrandonXLF/FloatHead]]

// === SCRIPTS BY OTHER USERS ===
// use <nowiki>{{lusc|script}}</nowiki>

if (window.rw == null) {
	// mw.loader.load("http://localhost:45991/ultraviolet.js");
    importScript("User:10nm/beta.js"); // [[User:10nm/beta.js]]
    // importScript("User:RedWarn/.js"); // [[User:RedWarn/.js]]
}

// Disabling this on typhoon articles due to the massive page load lag.
if (!/(typhoon|hurricane|cyclone) season$/gi.test(mw.config.get("wgPageName")))
	importScript("User:Novem Linguae/Scripts/CiteHighlighter.js"); // [[User:Novem Linguae/Scripts/CiteHighlighter.js]]
// This conflicts with RecentChanges styling.
if (mw.config.get("wgPageName") !== "Special:RecentChanges")
	importScript("User:Bradv/Scripts/ExpandDiffs.js"); // [[User:Bradv/Scripts/ExpandDiffs.js]]
if (/\massrb=\b/.test(location.search))
	importScript("User:Writ Keeper/Scripts/massRollback.js"); // [[User:Writ Keeper/Scripts/massRollback.js]]

importScript("User:Þjarkur/NeverUseMobileVersion.js"); // [[User:Þjarkur/NeverUseMobileVersion.js]]
// importScript("User:Evad37/EditWarChecker.js"); // [[User:Evad37/EditWarChecker.js]]
importScript("User:BrandonXLF/QuickEdit.js"); // [[User:BrandonXLF/QuickEdit.js]]
// importScript("User:Mxn/CommentsInLocalTime.js"); // [[User:Mxn/CommentsInLocalTime.js]]
importScript("User:Mvolz/displayContributions.js"); // [[User:Mvolz/displayContributions.js]]
importScript("User:Anne drew/PageDetails.js"); // [[User:Anne drew/PageDetails.js]]
importScript("User:Enterprisey/fancy-diffs.js"); // [[User:Enterprisey/fancy-diffs.js]]
importScript("User:Amorymeltzer/userinfo.js"); // [[User:Amorymeltzer/userinfo.js]]
importScript("User:Evad37/rename editors.js"); // [[User:Evad37/rename editors.js]]
importScript("User:Enterprisey/cv-revdel.js"); // [[User:Enterprisey/cv-revdel.js]]
importScript("User:Zhaofeng Li/Reflinks.js"); // [[User:Zhaofeng Li/Reflinks.js]]
importScript("User:Evad37/OneClickArchiver.js"); // [[User:Evad37/OneClickArchiver.js]]
importScript("User:Bradv/endlesscontribs.js"); // [[User:Bradv/endlesscontribs.js]]
// importScript("User:Bradv/Scripts/Superlinks.js"); // [[User:Bradv/Scripts/Superlinks.js]]
importScript("User:MJL/Archer.js"); // [[User:MJL/Archer.js]]
importScript("User:Awesome Aasim/noeditredlinks.js"); // [[User:Awesome Aasim/noeditredlinks.js]]
// importScript("User:P999/Toggle VF.js"); // [[User:P999/Toggle VF.js]]
importScript("User:Anomie/unsignedhelper.js"); // [[User:Anomie/unsignedhelper.js]]
importScript("User:Terasail/Edit Request Tool.js"); // [[User:Terasail/Edit Request Tool.js]]
importScript("User:Evad37/rater.js"); // [[User:Evad37/rater.js]]
importScript("User:SuperHamster/CiteUnseen.js"); // [[User:SuperHamster/CiteUnseen.js]]
importScript("User:BrandonXLF/CSSImageCrop.js"); // [[User:BrandonXLF/CSSImageCrop.js]]
importScript("User:Awesome Aasim/rcpatrol.js"); // [[User:Awesome Aasim/rcpatrol.js]]
importScript("User:DannyS712/DiscussionCloser.js"); // [[User:DannyS712/DiscussionCloser.js]]
importScript("User:Enterprisey/rfa-count-toolbar.js"); // Backlink: [[User:Enterprisey/rfa-count-toolbar.js]]
importScript('User:Ohconfucius/script/MOSNUM dates.js'); // Backlink: [[User:Ohconfucius/script/MOSNUM dates.js]]
importScript('User:MPGuy2824/MoveToDraft.js'); // Backlink: [[User:MPGuy2824/MoveToDraft.js]]
importScript('User:EnterpriseyBot/delsort.js'); // Backlink: [[User:EnterpriseyBot/delsort.js]]
importScript('User:Nardog/CopyCodeBlock.js'); // Backlink: [[User:Nardog/CopyCodeBlock.js]]
importScript('User:Novem Linguae/Scripts/DraftCleaner.js'); // Backlink: [[User:Novem Linguae/Scripts/DraftCleaner.js]]
importScript('User:SD0001/StubSorter.js'); // Backlink: [[User:SD0001/StubSorter.js]]
importScript('User:DannyS712/copyvio-check.js'); // Backlink: [[User:DannyS712/copyvio-check.js]]
importScript('User:Epicgenius/ArticleQuality.js'); // Backlink: [[User:Epicgenius/ArticleQuality.js]]
importScript('User:SD0001/GAN-helper.js'); // Backlink: [[User:SD0001/GAN-helper.js]]