User:Ursuul/global.js

//////////////////////////////////////////////// /************ Functions — ************/ //////////////////////////////////////////////// /* Last stable version of MultipleFileDelete/code.js */ var ug   = mw.config.get("wgUserGroups"), page = mw.config.get("wgCanonicalSpecialPageName"), token = mw.user.tokens.get("editToken"), pages = [ // Type 1 - enumerated 'Listredirects', 'BrokenRedirects', 'Unusedcategories', 'Unusedtemplates', // Type 2 - multi-column list 'Allpages', 'Prefixindex', // Type 3 - gallery 'Unusedimages', 'UnusedVideos' ];
 * (function($, mw) {

if (pages.indexOf(page) < 0 ||    !/vstf|staff|helper|sysop|content-moderator|content-team-member|content-volunteer|wiki-manager/.test(ug.join)) return;

// Allow users to disable script on certain pages if desired if (typeof(window.mfdExclude) !== 'undefined') { if (window.mfdExclude === page) return;

if (Array.isArray(window.mfdExclude) && window.mfdExclude.indexOf(page) >= 0) return; }

if ($('#btn-mfd-del').length && $('#btn-mfd-check').length) return;

if ($('.btn-mfd-start').length) $('.btn-mfd-start').remove;

var startBtn = '\ Selective Delete';

// Types 1 and 3 $('#mw-content-text .mw-spcontent .emptymwmsg.mediawiki_showingresults').nextAll('p').append(startBtn); // Type 2: all pages $('#mw-content-text .mw-allpages-table-form input[type="submit"]').after(startBtn); // Type 2: pages with prefix if ($('#mw-content-text').find('#mw-prefixindex-list-table').length > 0) $('#mw-content-text #nsselect input[type="submit"]').after(startBtn);

// Set up button click $('.btn-mfd-start').click(function {     startSelectiveDelete;   });

function apiDelete(page, reason) { new mw.Api.post({        format: 'json',         action: 'delete',         title:  page,         reason: reason,         bot:    true,         token:  token      }) .done(function(d) {         if (!d.error)            console.log('Deletion of ' + page + ' successful!');         else            console.log('Failed to delete ' + page + ': '+ d.error.code);      }) .fail(function {        console.log('Failed to delete ' + page + '!');      }); }

function startSelectiveDelete { $('.btn-mfd-start').remove;

var chk = ' '; var btns = '\ Delete Selected \ Check All';

// Type 1 $('#mw-content-text').find('ol').before(btns);

$('#mw-content-text').find('ol li > a').each(function {        if (!$(this).parent.find('input').length)            $(this).parent.prepend(chk);      });

// Type 2 $('#mw-content-text').find('.mw-allpages-table-chunk').before(btns);

$('#mw-content-text').find('.mw-allpages-table-chunk td a').each(function {        if (!$(this).parent.find('input').length)           $(this).parent.prepend(chk);      });

$('#mw-content-text').find('#mw-prefixindex-list-table').before(btns);

$('#mw-content-text').find('#mw-prefixindex-list-table td a').each(function {        if (!$(this).parent.find('input').length)         $(this).parent.prepend(chk);      });

// Type 3 $('#mw-content-text').find('ul').before(btns);

$('#mw-content-text').find('ul li .gallerytext > a').each(function {        if (!$(this).parent.find('input').length)            $(this).parent.prepend(chk);      });

$('#btn-ftd-del').click(function {        if ($('.selectiveDel:checked').length < 1)            return alert('No files selected.');

var deleteReason = prompt('Please enter the delete reason', 'Housekeeping');

if (!deleteReason) return;

$('.selectiveDel').each(function {           var chkObj = $(this);            var title  = $(this).parent.find('a').first.attr('title');

if (chkObj.attr('Checked')) { apiDelete(title, deleteReason); $(this).parent.css({'color':'grey','text-decoration':'line-through'}).children.removeAttr('href').css({'color':'grey','text-decoration':'line-through'}); }        });

setTimeout((function{ location.reload; }), 5000);     });

$('#btn-ftd-check').click(function {        var btn = $(this);

if (btn.text == 'Uncheck All') { $('.selectiveDel').each(function {              var chkObj = $(this);

if (chkObj.attr('checked')) chkObj.removeAttr('checked'); });

btn.text('Check All'); }        else { $('.selectiveDel').each(function {              var chkObj = $(this);

if (!chkObj.attr('checked')) chkObj.attr('checked','checked'); });

btn.text('Uncheck All'); }     });    } })(this.jQuery, this.mediaWiki);

/* Variable(s) */ var config = mw.config.get([   'wgCityId',    'wgContentLanguage',    'wgFormattedNamespaces' ]);

var u = config.wgFormattedNamespaces[2];

var user, talk; switch (config.wgContentLanguage) { case 'es': user = '', talk = ''; break; case 'fr': user = '', talk = ''; break; case 'zh': case 'zh-tw': case 'zh-hk': user = '', talk = ''; break; default: user = '', talk = ''; }//End V*/

/* Responsive Mobile * $('head').append('');/**/

/* Redundant User Talk links */ require(['jquery', 'wikia.window'], function (jQuery, wk) {   if (wk.wgCityId === '177') {        return;    }    jQuery.nirvana.getJson( 'WikiFeaturesSpecialController', 'index' ).done(function ($data) { if (           !$data.error &&            $data.features[4].name === 'wgEnableWallExt' &&            $data.features[4].enabled === true        ) { mw.util.addCSS(               '.ns-2 .wds-dropdown__content #ca-talk {' +                    'display: none;' +                '}'            ); }   }); });//End RUTL*/

/* Reorder SUG */ function ShowUserGroups_sorter(a, b) { var PredeterminedOrder = { 'staff':                      -120, 'util':                       -119, 'restricted-login':           -118, 'restricted-login-auto':      -117, 'restricted-login-exempt':    -116, 'devboxpanel':                -115, 'translator':                 -114, 'content-reviewer':           -113, 'lookupuser':                 -112, 'lookupcontribs':             -111, 'wiki-manager':               -100, 'content-team-member':         -90, 'helper':                      -80, 'vstf':                        -70, 'global-discussions-moderator': -60, 'voldev':                      -50, 'content-volunteer':           -40, 'vanguard':                    -30, 'council':                     -20, 'authenticated':               -10, 'fandom-editor':                 0, 'bot-global':                   10, 'bot':                         110, 'codeadmin':                   120, 'checkuser':                   130, 'bureaucrat':                  140, 'sysop':                       150, 'content-moderator':           160, 'threadmoderator':             170, 'chatmoderator':               180, 'rollback':                    190, 'autoconfirmed':               200, 'emailconfirmed':              210 };   var sortA = typeof PredeterminedOrder[a] === 'number' ? PredeterminedOrder[a] : 100;   var sortB = typeof PredeterminedOrder[b] === 'number' ? PredeterminedOrder[b] : 100;   return sortA - sortB; }//End RSUG*/

//////////////////////////////////////////////// /*************** Import Configs ***************/ //////////////////////////////////////////////// /* General */ window.anchoredRollbackBot                 = true; window.GlobalChatJS_useServiceWorker       = true; window.SeeMoreActivityButtonRC             = true; window.nullEditDelay                       = 250; window.batchDeleteDelay                    = 250; window.massCategorizationDelay             = 250; window.WHAMDelay                           = 250; window.massProtectDelay                    = 250; window.massRenameDelay                     = 250; window.massRenameSummary                   = 'Automatic Process'; window.mobileText                          = 'Switch to Mercury'; window.cvCaseSensitive                     = 'checked'; window.railWAM = { load: true }; window.massEditConfig = { editInterval: 750 }; window.BotManagement = { add: 'Temporary for execution of light automatic tasks', remove: 'Done' }; window.configMessage = { interval: 750, placement: { element: 'tools', type: 'prepend' } }; window.AutoCreateUserPagesConfig = { content: { 2:    user, 3:    talk, 1202: talk },   summary:   'Creating Profile' }; window.announcementsIgnore = { option: 'opt-in-all', exceptWikiIds: [ 1547755,//Surviv 1136286,//Overlord 993749,//Animal Jam Clans 338386,//Attack on Titan 621556,//SU 1903,//Acepedia 1706//TES ] };//End G*/

/* FastCreate */ window.FCButtons = ;//End FC*/

/* Code Quick Links */ window.customCodeQuickLinks = { replaceAllDefaultLinks: true, linkSet: { siteFiles: [{ name: 'JSPages', href: mw.util.getUrl('Special:JSPages') }, {           name: 'ImportJS', href: mw.util.getUrl('MediaWiki:ImportJS') }, {           name: 'Themes.css', href: mw.util.getUrl('MediaWiki:Themes.css') }, {           name: 'Common.js', href: mw.util.getUrl('MediaWiki:Common.js') }, {           name: 'Common.css', href: mw.util.getUrl('MediaWiki:Common.css') }, {           name: 'Wikia.js', href: mw.util.getUrl('MediaWiki:Wikia.js') }, {           name: 'Wikia.css', href: mw.util.getUrl('MediaWiki:Wikia.css') }, {           name: 'Chat.js', href: mw.util.getUrl('MediaWiki:Chat.js') }, {           name: 'Chat.css', href: mw.util.getUrl('MediaWiki:Chat.css') }, {           name: 'S:AI', href: mw.util.getUrl('Special:AllInfoboxes') }, {           name: 'S:I/PP', href: mw.util.getUrl('Special:Insights/popularpages') }, {           name: 'S:I/NPI', href: mw.util.getUrl('Special:Insights/nonportableinfoboxes') }],       userFiles: [{ name: 'Global.js', href: '//community.fandom.com/wiki/Special:MyPage/global.js' }, {           name: 'ImportCSS', href: '//community.fandom.com/wiki/Special:MyPage/global.css' }, {           name: 'Global.css', href: '//community.fandom.com/wiki/Special:MyPage/g.css' }, {           name: 'Common.js', href: mw.util.getUrl('Special:MyPage/common.js') }, {           name: 'Common.css', href: mw.util.getUrl('Special:MyPage/common.css') }, {           name: 'Wikia.js', href: mw.util.getUrl('Special:MyPage/wikia.js') }, {           name: 'Wikia.css', href: mw.util.getUrl('Special:MyPage/wikia.css') }, {           name: 'Chat.js', href: mw.util.getUrl('Special:MyPage/chat.js') }, {           name: 'Chat.css', href: mw.util.getUrl('Special:MyPage/chat.css') }, {           name: 'Subpages', href: mw.util.getUrl('Special:PrefixIndex/User:Ursuul/') }, {           name: 'Sandbox', href: mw.util.getUrl('Special:Mypage/Sandbox') }, {           name: 'Properties', href: '//community.fandom.com/wiki/User:Ursuul/properties.css?action=edit' }]   } };//End CQL*/

//////////////////////////////////////////////// /******************* Imports ******************/ //////////////////////////////////////////////// /* Universal Imports */ importArticles({   type: 'script',    articles: [        'u:dev:AjaxBatchDelete.js',        //'u:dev:AjaxEdit.js',        'u:dev:AjaxUndo/code.js',        'u:dev:AnchoredRollback/code.js',        'u:dev:AnnouncementsIgnore.js',        'u:dev:BlogLink/code.js',        'u:dev:BotManagement.js',        'u:dev:CodeEditor.js',        'u:dev:CodeQuickLinks/code.js',        'u:dev:ContribsButtons.js',        'u:dev:DisableInfoboxBuilder.js',        'u:dev:DiscussionsViewer.js',        'u:dev:EditConflictAlert/code.js',        'u:dev:FastCreate.js',        'u:dev:FileLogs.js',        'u:dev:FindAndReplace/code.js',        'u:dev:FixJSRTLang.js',        'u:dev:GlobalChatJS.js',        'u:dev:LastEdited/code.js',        'u:dev:LinkToDiscussionsProfileIfTheyDontHaveLivePosts/code.js',        'u:dev:MarkBlocked.js',        'u:dev:MassCategorization/code.js',        'u:dev:MassEdit/code.js',        'u:dev:MassNullEdit/code.js', 'u:dev:MassProtect/code.js', 'u:dev:MassRename/code.js', 'u:dev:MassRenameRevert/code.js', 'u:dev:MastheadGender/code.js', 'u:dev:Message/code.js', 'u:dev:MinimalTemplateClassification.js', 'u:dev:MinimalTestModeAlert.js', 'u:dev:MobileEditor.js', //'u:dev:MultipleFileDelete/code.js',//do not remove über script 'u:dev:NullEditButton/code.js', 'u:dev:PageCreator/code2.js', 'u:dev:PageEditInfo/code.js', 'u:dev:PortableCSSPad/code.js', 'u:dev:PortableListUsers.js', 'u:dev:ProtectionIcons.js', 'u:dev:RCLink.js', 'u:dev:RCStats.js', 'u:dev:RedirectManagement/code.js', 'u:dev:ReferencePopups/code.js', //'u:dev:SavedDrafts.js', 'u:dev:SearchSuggest/code.js', 'u:dev:SeeMoreActivityButton/code.js', 'u:dev:ShowUserGroups.js', 'u:dev:SkinSwitchButton/code.js', 'u:dev:Thread Inspection/code.js', 'u:dev:UnhideUserMasthead/code.js', 'u:dev:UnsafeScripts/code.js', //'u:dev:View Source/code.js', 'u:dev:VSTFReport.js', 'u:dev:WHAM/code.2.js', 'u:dev:WLHEditLinks/code.js', 'u:dev:WallGreetingButton/code.js', 'u:dev:Wikimarks/code.js', 'u:dev:WorkingMoreUsersCount.js', 'u:elderscrolls:Common.js/DiscussionsLinks.js', 'u:kocka:User:KockaAdmiralac/AutoCreateUserPages.javascript', 'u:thegoldenpatrik1:Rollback.js' ] });//End UI*/

/* Wiki-specific imports */ if ('65099' === config.wgCityId) { importArticle({       type: 'style',        article: 'u:dev:MediaWiki:FANSUN.css'    }); }

if (['193260', '65099'].indexOf(config.wgCityId) !== -1) { importArticle({       type: 'script',        article: 'u:dev:FANSUN.js'    }); }//End WSI*/