User:OttoLannister550/global.js

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:MassEdit/code.js',        'u:dev:MediaWiki:MassCategorization/code.js',        'u:dev:MediaWiki:FindAndReplace/code.js',        'u:dev:MediaWiki:AjaxRename/code.js',        'u:dev:MediaWiki:AjaxEdit.js',        'u:dev:MediaWiki:AjaxRedirect/code.js',        'u:dev:MediaWiki:MassNullEdit/code.js',        'u:dev:MediaWiki:AjaxDelete/code.js',        'u:dev:MediaWiki:AjaxBatchDelete.js',        'u:dev:MediaWiki:AjaxBatchUndelete.js',        'u:dev:MediaWiki:AjaxEditPreview.js',        'u:dev:MediaWiki:WhatLinksHere/code.js',        'u:dev:MediaWiki:TopArticles/code.js',        'u:dev:MediaWiki:MassRename/code.js',        'u:dev:MediaWiki:DisplayTimer/code.js',        'u:dev:MediaWiki:NullEditButton/code.js',        'u:dev:MediaWiki:DisableCode/code.js',        'u:dev:MediaWiki:PageCreator/code2.js',        'u:dev:MediaWiki:ThemeToggler.js', 'u:dev:MediaWiki:DateInserter/code.js', 'u:dev:MediaWiki:QuickPurge.js', 'u:dev:MediaWiki:SkinSwitchFD.js', 'u:dev:MediaWiki:MultiUpload.js', 'u:dev:MediaWiki:ImageMapEdit.js', 'u:dev:MediaWiki:ImageMapEditZoom.js', 'u:dev:MediaWiki:MobilePreview.js', 'u:dev:MediaWiki:ArticlePreview/code.js', ] });

//Previous Wiki Determinator /* * Note: - currWiki: the current wiki the user visited based on the data from the wgServer configuration value. - prevWiki: last wiki the user visited other than CC based on the data from the userJS-prevWiki preference option. - Conditional 1.a: If the user is visiting non-CC wiki but userJS-prevWiki preference option is still yet to be created, set the params variable value to as follows. - Conditional 1.b: If the user is visiting non-CC wiki and userJS-prevWiki preference has been created (containing a value), set the params variable value to as follows. - Conditional 1.c: If the user is on CC, replace the CC button on the global nav with the Previous Wiki button. - Conditional 2 : If either 1.a or 1.b happen, use the params variable value to specify the API request and send it. */ mw.loader.using('mw.Api', function {   var currWiki = mw.config.get('wgServer'),        prevWiki = mw.user.options.get('userJS-prevWiki'),        params;    if (currWiki != 'https://community.fandom.com' && prevWiki === null) {       //Cond. 1.a.        params = {            action: 'options',            optionname: 'userJS-prevWiki',            optionvalue: currWiki,            format: 'json'        };    } else if (currWiki != 'https://community.fandom.com') {        //Cond. 1.b.        params = {            action: 'options',            change: 'userJS-prevWiki=' + currWiki,            format: 'json'        };    } else {        //Cond. 1.c        var ccButton = document.querySelector('.global-navigation .wds-dropdown__content a[href*="community.fandom.com"]');        ccButton.textContent = 'Previous Wiki';        ccButton.href = (!prevWiki) ? currWiki : prevWiki;    }    if (currWiki != 'https://community.fandom.com') {        //Cond. 2        var api = new mw.Api;        api.postWithToken('csrf', params).done(function(data) { console.log(data); });   } });

/* Adding Personal CSS, Personal JS, Wiki CSS, and Wiki JS to the Wiki Tools' Dropdown */ $(function { //Sub Menus Creation Function	function createSubMenus(submenuNames, type, scope) {		var submenuContainer_ul = document.createElement('ul');    	submenuContainer_ul.className = 'wds-list wds-is-linked';    	var i, submenu_a, submenu_li, phpNames;    	for (i = 0; i < submenuNames.length; i++) {		    submenu_a = document.createElement('a');		    switch (scope) {				case 'Personal':    				submenu_a.href = '/wiki/Special:MyPage/' + submenuNames[i].toLowerCase     								  + '.' + type.toLowerCase;    				phpNames = '/index.php?title=Special:MyPage/' +submenuNames[i].toLowerCase     								  + '.' + type.toLowerCase;    				break;				case 'Wiki':    				submenu_a.href = '/wiki/MediaWiki:' + submenuNames[i] + '.'     								  + type.toLowerCase;    				phpNames = '/index.php?title=MediaWiki:' +submenuNames[i] + '.'     								  + type.toLowerCase;				}				$.ajax({ type: 'HEAD', url: phpNames, error: submenu_a.style.opacity = '0.5' });   	    submenu_a.id = scope + '_' + submenuNames[i] + '_' + type;    	    submenu_a.innerHTML = submenuNames[i] + ' ' + type;    	    submenu_li = document.createElement('li');         	submenu_li.appendChild(submenu_a);    	    submenuContainer_ul.appendChild(submenu_li);    	}    	var submenuContainer_div = document.createElement('div');    	submenuContainer_div.className = 'wds-is-not-scrollable wds-dropdown-level-2__content';    	submenuContainer_div.appendChild(submenuContainer_ul);    	return submenuContainer_div;	} //Creating the Sub Menus	var personalCSSSubMenus = ['Common', 'Fandomdesktop', 'FandomMobile', 'Oasis'];	var personalJSSubMenus = ['Common', 'Fandomdesktop', 'FandomMobile', 'Oasis'];	var wikiCSSSubMenus = ['Common', 'Fandomdesktop', 'Wikia', 'Print',					   'Group-autoconfirmed', 'Group-sysop', 'Group-bot'];	var wikiJSSubMenus = ['Common', 'Fandomdesktop', 'Wikia', 'Group-autoconfirmed', 'Group-sysop', 'Group-bot']; var menuContent = []; menuContent[0] = createSubMenus(personalCSSSubMenus,'CSS','Personal'); menuContent[1] = createSubMenus(personalJSSubMenus,'JS','Personal'); menuContent[2] = createSubMenus(wikiCSSSubMenus,'CSS','Wiki'); menuContent[3] = createSubMenus(wikiJSSubMenus,'JS','Wiki'); //Creating the Menus var menu_a, menu_li; var menus = ['Personal CSS', 'Personal JS', 'Wiki CSS', 'Wiki JS']; var wikiToolsDropdown = document.querySelectorAll('.wiki-tools .wds-dropdown__content>ul.wds-list'); for (i = 0; i < menus.length; i++) { menu_a = document.createElement('a'); menu_a.href = '#'; menu_a.id = menus[i].replace(' ', '_'); menu_a.innerHTML = menus[i]; menu_li = document.createElement('li'); menu_li.className = 'wds-dropdown-level-2 is-calculated css-js_pages_li'; menu_li.appendChild(menu_a); menu_li.appendChild(menuContent[i]); wikiToolsDropdown[0].appendChild(menu_li); wikiToolsDropdown[1].appendChild(menu_li); } //Styling the Menus var cssjsPageMenus_li = document.getElementsByClassName('css-js_pages_li'); var cssjsPageMenus_a = document.querySelectorAll('.wds-dropdown__content .css-js_pages_li>a'); var cssjsPageSubMenus_div = document.querySelectorAll('.css-js_pages_li>div.wds-dropdown-level-2__content'); for (i = 0; i < cssjsPageMenus_li.length; i++) { cssjsPageMenus_li[i].style.marginRight = '9px'; cssjsPageMenus_li[i].style.marginLeft = '0'; cssjsPageMenus_a[i].style.paddingLeft = '19px'; cssjsPageSubMenus_div[i].style.left = 'inherit'; cssjsPageSubMenus_div[i].style.right = '100%'; } });