Jump to content

User:Zackmann08/scripts/JWB.js/load.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.
/** This script contains the code required for loading [[User:Zackmann08/scripts/JWB.js]].
 *  All other code is located at that page.
 */

//Idea by [[User:Epicgenius]]
$.when(mw.loader.using(['mediawiki.util'], $.ready)).done( function() {
	mw.util.addPortletLink(
		"p-tb", 
		mw.config.get('wgArticlePath').replace('$1', "User:Zackmann08/scripts/JWB.js/loader"), 
		"Z Wiki Browser", 
		"tb-awbscript", 
		"Run Javascript Wiki Browser"
		);
});
const allowed_users = ['Zackmann08', 'Phuzion', 'WikipediholicRat']
if (mw.config.get('wgCanonicalNamespace')+':'+mw.config.get('wgTitle') === 'User:Zackmann08/scripts/JWB.js/loader'){
	if (!allowed_users.includes(mw.config.get('wgUserName'))) { 
		alert('ERROR: You do not have permission to use this tool. Contact Zackmann08 for access.');
	} else {
		mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Zackmann08/scripts/JWB.js&action=raw&ctype=text/javascript');	
	}
}