User:Snowmanonahoe/common.js

// Enable caching for resource loads, see User:SD0001/Making_user_scripts_load_faster, @revision 6 if (!/\bnocache=\b/.test(location.href)) { // Don't enable if nocache=1 url parameter is given let loadResource = (page, sitename, ctype) => { page = page.replace(/special:mypage/i, 'User:' + mw.config.get('wgUserName')); return $.get(			'https://' + sitename + '/w/api.php?titles=' + page + // page is already URL-encoded			'&origin=*&format=json&formatversion=2&uselang=content&maxage=86400&smaxage=86400' + 			'&action=query&prop=revisions|info&rvprop=content&rvlimit=1'		).then((apiResponse) => {			let apiPage = apiResponse.query.pages[0];			if (apiPage.missing) {				return;			}			let content = apiPage.revisions[0].content;			if ((!ctype || ctype === 'text/javascript') && apiPage.contentmodel === 'javascript') {				let scriptTag = document.createElement('script');				scriptTag.innerHTML = content;				document.head.appendChild(scriptTag);		   } else if (ctype === 'text/css' && apiPage.contentmodel === 'css') {				mw.loader.addStyleTag(content);			} else {				return $.Deferred.reject('Refused to load "' + page + '"@' + sitename + ': content type mismatch');			}		}); };	let getSiteTitle = (url) => { let siteRgx = /^(?:(?:https:)?\/\/(.*))?\/w\/index.php/.exec(url), titleRgx = /\btitle=([^=?&]*)/.exec(url); if (siteRgx && titleRgx && /\baction=raw\b/.test(url) && /\bctype=/.test(url)) { return [titleRgx[1], siteRgx[1] || mw.config.get('wgServerName')]; } else return null; };	window.importScript = (page) => { loadResource(encodeURIComponent(page), mw.config.get('wgServerName'), 'text/javascript'); };	window.importStyleSheet = (page) => { loadResource(encodeURIComponent(page), mw.config.get('wgServerName'), 'text/css'); };	let oldMwLoaderLoad = mw.loader.load; mw.loader.load = function(url, type) { let linkParts = getSiteTitle(url); if (linkParts) { loadResource(linkParts[0], linkParts[1], type); } else { oldMwLoaderLoad.apply(mw.loader, [...arguments]); }	};	let oldMwLoaderGetScript = mw.loader.getScript; mw.loader.getScript = function(url) { let linkParts = getSiteTitle(url); if (linkParts) { return loadResource(linkParts[0], linkParts[1], 'text/javascript'); } else { return oldMwLoaderGetScript.apply(mw.loader, [...arguments]); }	}; } sciNoConfirm=true; importScript('User:Jackmcbarn/editProtectedHelper.js'); // Backlink: User:Jackmcbarn/editProtectedHelper.js mw.loader.load( "https://meta.wikimedia.org/w/index.php?title=User:Zhaofeng_Li/Reflinks.js&action=raw&ctype=text/javascript" ); // Backlink: m:User:Zhaofeng_Li/Reflinks.js importScript('User:10nm/beta.js'); // Backlink: User:10nm/beta.js importScript('User:Writ Keeper/Scripts/massRollback.js'); // Backlink: User:Writ Keeper/Scripts/massRollback.js importScript('User:Trappist the monk/HarvErrors.js'); // Backlink: User:Trappist the monk/HarvErrors.js importScript('User:GeneralNotability/mark-locked.js'); // Backlink: User:GeneralNotability/mark-locked.js importScript('User:BrandonXLF/FFUHelper.js'); // Backlink: User:BrandonXLF/FFUHelper.js importScript('User:SD0001/deleted-metadata-link.js'); // Backlink: User:SD0001/deleted-metadata-link.js importScript('User:PleaseStand/userinfo.js'); // Backlink: User:PleaseStand/userinfo.js importScript('User:Ingenuity/AntiVandal.js'); // Backlink: User:Ingenuity/AntiVandal.js mw.loader.load( '/w/index.php?title=User:Joeytje50/JWB.js/load.js&action=raw&ctype=text/javascript' ); // Backlink: User:Joeytje50/JWB.js/load.js importScript('User:Evad37/OneClickArchiver.js'); // Backlink: User:Evad37/OneClickArchiver.js importScript('User:Enterprisey/cv-revdel.js'); // Backlink: User:Enterprisey/cv-revdel.js importScript('User:Epicgenius/ArticleQuality.js'); // Backlink: User:Epicgenius/ArticleQuality.js importScript('User:Evad37/rater.js'); // Backlink: User:Evad37/rater.js importScript('User:MPGuy2824/MoveToDraft.js'); // Backlink: User:MPGuy2824/MoveToDraft.js importScript('User:Jackmcbarn/advancedtemplatesandbox.js'); // Backlink: User:Jackmcbarn/advancedtemplatesandbox.js importScript('User:Enterprisey/sync-template-sandbox.js'); // Backlink: User:Enterprisey/sync-template-sandbox.js