User:C.Syde65/global.js

AjaxRCRefreshText = 'Auto-refresh'; AjaxRCRefreshHoverText = 'Automatically refresh the page'; ajaxPages = ["Special:RecentChanges", "Special:WikiActivity"];

window.UserTagsJS = { modules: { inactive: 62, newuser: true, autoconfirmed: true, mwGroups: [ 'bureaucrat', 'sysop', 'assistant', 'rollback', 'chatmoderator', 'bannedfromchat' ]   },    tags: { assistant: 'Assistant', threadmoderator: 'Discussions Moderator', 'content-moderator': 'Content Moderator' },   oasisPlaceBefore: '' };

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:ChatHacks.js',        'u:dev:MediaWiki:EditIntroButton/code.js',        'u:dev:MediaWiki:AjaxRC/code.js',        'u:dev:MediaWiki:PurgeButton/code.js',        'u:dev:MediaWiki:UserTags/code.js',        'u:dev:MediaWiki:RevealAnonIP/code.js'    ] });

/* mw.loader.using(['mediawiki.util', 'mediawiki.api'], function {
 * Nuke
 * Reverse engineered Nuke extension
 * https://www.mediawiki.org/wiki/Extension:Nuke is the page of the official MW extension
 * @author Ozank Cx
 * @todo - implement usercontribs API if Wikia update to MW 1.23+

var ug = mw.config.get('wgUserGroups');

if (ug.indexOf('content-moderator') + ug.indexOf('sysop') + ug.indexOf('vstf') + ug.indexOf('staff') + ug.indexOf('helper') == -5) return;

var config = mw.config.get([	'skin',	'stylepath',	'wgArticlePath',	'wgFormattedNamespaces',	'wgMainpage',	'wgSiteName' ]), token = mw.user.tokens.values.editToken, API = new mw.Api, deleteDelay = window.nukeDelay || 1000; config.wgArticlePath = config.wgArticlePath.slice(0,-2);

var self = { init: function { $('.header-column.header-title h1').text('Nuke'); document.title = "Nuke - " + config.wgSiteName; if ($.getUrlVar('nukeuser')) { var user = $.getUrlVar('nukeuser'), deleteReason = window.nukeDeleteReason || "Mass removal of pages created by " + user.replace(/_/g,' '); $('#mw-content-text p').html('Switch to Nuke main form The following pages were created by ' + user.replace(/_/g,' ') + '; put in a comment and hit the button to delete them. Reason for deletion:  Delete Delete'); $('#nuke-status').html('Getting pages... please wait '); API.get({			action: 'query',			list: 'usercontribs',			ucnamespace: $.getUrlVar('nukenamespace') || '',			ucuser: user,			uclimit: 5000,			cb: new Date.getTime 			}) .done(function(d) {				if (!d.error) {					var usercontribs = d.query.usercontribs,					maxLimit = $.getUrlVar('nukelimit') || 500,					count = 0,					images = [];					for (var i in usercontribs) {						if (count >= maxLimit) break;						if (usercontribs[i].hasOwnProperty('new')) {							var escapedTitle = encodeURIComponent(usercontribs[i].title);							if (!$.getUrlVar('nukematch') || new RegExp($.getUrlVar('nukematch')).test(usercontribs[i].title)) {								$('#nuke-query-results').append(' ' + usercontribs[i].title + '</li>');								if (usercontribs[i].title.slice(0,5) == "File:")									images.push(usercontribs[i].title);								count++;															}						}					}					if (!$('.nuke-query-result').length)						self.outputError("No user contributions found"); else { if (images.length > 0) self.displayImages(images); }				}				else self.outputError("Failed to get user contributions: " + d.error.code); })			.fail(function { self.outputError("Failed to get user contributions"); });			$('#nuke-status').empty;		}		else {			$('#mw-content-text p').html('This tool allows for mass deletions of pages recently added by a given user or IP address. Input the username or IP address to get a list of pages to delete, or leave blank for all users. Username, IP address or blank: <input type="text" id="nuke-username"/> Pattern for the page name: <input type="text" id="nuke-match"/> Limit to namespace: <select id="nuke-namespace"><option value="All">All <option value="Main" ns="0">Main <option value="Project" ns="4">Project <option value="Project talk" ns="5">Project talk <option value="Talk" ns="1">Talk <option value="User" ns="2">User <option value="User talk" ns="3">User talk <option value="File" ns="6">File <option value="File talk" ns="7">File talk <option value="Template" ns="10">Template <option value="Template talk" ns="11">Template talk <option value="Help" ns="12">Help <option value="Help talk" ns="13">Help talk <option value="Category" ns="14">Category <option value="Category talk" ns="15">Category talk Maximum number of pages: <input type="text" id="nuke-max" value="500"/> <a class="wikia-button" id="nuke-rc">Go</a>  '); $('#nuke-rc').click(function {				if ($(this).attr('disabled')) return;				$(this).attr('disabled','disabled');				if ($('#nuke-username').val) {					var locationStr = config.wgArticlePath + 'Special:Blankpage?blankspecial=nuke&nukeuser=' + $('#nuke-username').val;					if ($('#nuke-namespace').val != "All")						locationStr += '&nukenamespace=' + $('#nuke-namespace option:selected').attr('ns');					if ($.isNumeric($('#nuke-max').val) && $('#nuke-max').val > 0)						locationStr += '&nukelimit=' + $('#nuke-max').val;					if ($('#nuke-match').val)						locationStr += '&nukematch=' + $('#nuke-match').val;					location.replace(locationStr);					return;				}				$('#nuke-query-results').empty;				if ($('.nuke-submit').length) {					$('.nuke-submit').remove;					$('#mw-content-text > p:nth-child(1) > br:nth-child(14)').remove;				}				$('#nuke-status').html('Getting pages... please wait <img src="' + config.stylepath + '/common/progress-wheel.gif"/>');				API.get({ action: 'query', list: 'recentchanges', rcshow: '!bot', rctype: 'new|log', rclimit: 5000, cb: new Date.getTime })				.done(function(d) { if (!d.error) { var recentchanges = d.query.recentchanges, RCTitles = [], maxLimit = $('#nuke-max').val || 5000, count = 0, images = []; for (var i in recentchanges) { if (count >= maxLimit) break; if ($.inArray(recentchanges[i].title,RCTitles) == -1 && (($('#nuke-namespace').val == "Main" && recentchanges[i].title.split(':').length === 1) || $('#nuke-namespace').val == "All" || $('#nuke-namespace').val == "Project" && new RegExp(config.wgFormattedNamespaces[4] + ':').test(recentchanges[i].title) || $('#nuke-namespace').val == "Project talk" && new RegExp(config.wgFormattedNamespaces[5] + ':').test(recentchanges[i].title) || new RegExp($('#nuke-namespace').val + ':').test(recentchanges[i].title)) && (recentchanges[i].type == "new" || (recentchanges[i].type == "log" && recentchanges[i].ns == 6))) { if (!$('#nuke-match').val || new RegExp($('#nuke-match').val).test(recentchanges[i].title)) { RCTitles.push(recentchanges[i].title); var escapedTitle = encodeURIComponent(recentchanges[i].title); $('#nuke-query-results').append('<li class="nuke-query-result"><input type="checkbox" class="nuke-title-check" checked="checked"/> <a href="' + config.wgArticlePath + escapedTitle + '" target="_blank"> ' + recentchanges[i].title + '</a></li>'); if (recentchanges[i].title.slice(0,5) == "File:") images.push(recentchanges[i].title); count++; }							}						}						if (!$('.nuke-query-result').length) self.outputError("No recent changes found"); else { $('#nuke-query-results').before(' <a class="wikia-button nuke-submit">Delete</a>').after('<a class="wikia-button nuke-submit">Delete</a>'); $('#nuke-status').empty; if (images.length > 0) self.displayImages(images); }					}					else self.outputError("Failed to get recent changes: " + d.error.code); })				.fail(function { self.outputError("Failed to get recent changes"); });				$('#nuke-status').empty;				$(this).removeAttr('disabled');			}); }

$('.nuke-submit').click(function {			if (!$('.nuke-query-result').length || $(this).attr('disabled')) return;			$('.nuke-submit').attr('disabled','disabled');			$('#nuke-status').html('Deleting pages... please wait <img src="' + config.stylepath + '/common/progress-wheel.gif"/>');			$('.nuke-title-check:checked').each(function(i) { var title = $(this).parent.find('a').text; setTimeout(function {					API.post({ action: 'delete', title: title, reason: $('#nuke-delete-reason').val || '', bot: true, token: token })					.done(function(d) { if (!d.error) { console.log('Deletion of ' + title + ' successful!'); } 						else { console.log('Failed to delete ' + title + ': '+ d.error.code); }					})					.fail(function { console.log('Failed to delete ' + title); });					if (i === $('.nuke-title-check:checked').length - 1) {						setTimeout(function { location.replace(config.wgArticlePath + config.wgMainpage); }, 1000);	 					}				}, i*deleteDelay); });		});	},	outputError: function(text) { switch (config.skin) { case 'oasis': case 'wikia': new BannerNotification(text,'error').show; break; default: alert(text); break; }	},	displayImages: function(imgs) { API.post({ //POST instead of GET for longer length		action: 'query',		prop: 'imageinfo',		titles: imgs.join('|'),		iiprop: 'url',		iilimit: 500		}) .done(function(d) {			if (!d.error) {				mw.util.addCSS('.thumbnail-nuke { width: 120px; height: 77px; }');				for (var i in d.query.pages) {					if (d.query.pages[i].missing != "") {						var href = config.wgArticlePath + encodeURIComponent(d.query.pages[i].title);						$('a[href="' + href + '"]').parent.children('.nuke-title-check').after('<a href="' + href + '"><img class="thumbnail-nuke" src="' + d.query.pages[i].imageinfo[0].url + '" /></a>');					}				}			}			else				self.outputError('Failed to display images: ' + d.error.code);		}) .fail(function {				self.outputError('Failed to display images');					}); } };

switch (mw.config.get('wgCanonicalSpecialPageName')) { case "Contributions": $('#contentSub a:last-child').after(' | <a title="Special:Nuke" href="' + mw.config.get('wgArticlePath').replace('$1','Special:Blankpage?blankspecial=nuke&nukeuser=' + mw.config.get('wgPageName').split('/')[1] ) + '">Nuke</a>'); break; case "Specialpages": if (!$('a[title="Special:Nuke"]').length) $('.mw-specialpagerestricted a[title="Special:Undelete"]').after('<li class="mw-specialpagerestricted"><a title="Special:Nuke" href="' + mw.config.get('wgArticlePath').replace('$1','Special:Blankpage?blankspecial=nuke') + '">Mass delete</a></li>'); else $('.mw-specialpagerestricted a[title="Special:Nuke"]').after('<li class="mw-specialpagerestricted"><a title="Special:Nuke" href="' + mw.config.get('wgArticlePath').replace('$1','Special:Blankpage?blankspecial=nuke') + '">Mass delete (JavaScript)</a></li>'); break; case "Blankpage": if ($.getUrlVar('blankspecial') == "nuke") self.init; break; default: return; break; }

});

/*
 * Rollback
 * Perform rollbacks without needing to be in the usergroup
 * @author Ozuzanna

var main = { init: function { //check if user has rollback permission already var userGroups = ["rollback","content-moderator","assistant","sysop","vstf","helper","staff"], ownGroups = mw.config.get('wgUserGroups'), hasPermissionAlready = false; for (var i in ownGroups) { if (userGroups.indexOf(ownGroups[i]) !== -1) { hasPermissionAlready = true; break; }		}		if (hasPermissionAlready) return; if (mw.config.get('wgAction') == "history" && $('#pagehistory li').length > 1) $('#pagehistory li:first .mw-history-undo a').before(' <a style="cursor: pointer" title="&quot;Rollback&quot; reverts edit(s) to this page of the last contributor in one click" data-id="' + mw.config.get('wgPageName') + '">rollback</a> | '); else if (mw.config.get('wgCanonicalSpecialPageName') == "Contributions") { $('#mw-content-text ul').find('li').each(function {				if ($(this).find('.mw-uctop').length)					$(this).append(' [<a style="cursor: pointer" title="&quot;Rollback&quot; reverts edit(s) to this page of the last contributor in one click" data-id="' + $(this).find('a:first').attr('title') + '">rollback</a>] ');			}); }		else if (($.getUrlVar('diff') || $.getUrlVar('oldid')) && $('#differences-nextlink').length == 0) $('.mw-usertoollinks:last').after('   [<a style="cursor: pointer" title="&quot;Rollback&quot; reverts edit(s) to this page of the last contributor in one click" data-id="' + mw.config.get('wgPageName') + '">rollback</a>] '); $('.mw-custom-rollback-link a').click(function {			main.getRevisionIdAndContent($(this).attr('data-id'));		}); },	getRevisionIdAndContent: function(title) { var API = new mw.Api; API.get({		action: 'query',		prop: 'revisions',		titles: title,		rvprop: 'user|ids',		rvlimit: 500,		cb: new Date.getTime		}) .done(function(d) {			if (!d.error) {				var revisions;				for (var i in d.query.pages) {					revisions = d.query.pages[i].revisions;				}				var currentUser = revisions[0].user, //current user rollbacking from				lastUser,				revId;				for (var i in revisions) {					if (revisions[i].user != currentUser) {						lastUser = revisions[i].user; //remember last author						revId = revisions[i].revid; //get revision to revert to						break;					}				}				if (lastUser) {					API.get({ action: 'query', prop: 'revisions', rvprop: 'content', revids: revId, cb: new Date.getTime })					.done(function(d) { if (!d.error) { var content = ""; //can be no content on page so initialise empty as failsafe for (var i in d.query.pages) { if (d.query.pages[i].revisions) content = d.query.pages[i].revisions[0]["*"]; }							main.performRollback(title,content,currentUser,lastUser); }						else new BannerNotification('Unable to rollback (failed to get page content): ' + d.error.code,'error').show; })					.fail(function { new BannerNotification('Unable to rollback: failed to get page content!','error').show; });				}				else					new BannerNotification('Unable to rollback: no different editor found!','error').show;			}			else				new BannerNotification('Unable to rollback (failed to get revisions): ' + d.error.code,'error').show;		}) .fail(function {			new BannerNotification('Unable to rollback: failed to get revisions!','error').show;		}); },	performRollback: function(page,text,user,user2) { var API = new mw.Api; API.post({		action: 'edit',		title: page,		text: text,		summary: 'Reverted edits by ' + user + ' (talk | block) to last version by ' + user2 + ' (script)',		token: mw.user.tokens.values.editToken		}) .done(function(d) {			if (!d.error) {				new BannerNotification('Rollback successful!','confirm').show;							}			else				new BannerNotification('Unable to rollback (failed to publish edit): ' + d.error.code,'error').show;		}) .fail(function {			new BannerNotification('Unable to rollback: failed to publish edit!','error').show;		}); } }; main.init; }) (this.jQuery, this.mediaWiki); // Adds NavigationPopups // wikipedia:User:Lupin/popups mw.loader.load("//en.wikipedia.org/w/index.php?title=User:Lupin/popups.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400"); popupRevertSummary = 'Revert to revision dated %s by %s, oldid %s using popups'; popupQueriedRevertSummary = 'Revert to revision $1 dated $2 by $3 using popups'; popupExtendedRevertSummary = 'Revert to revision dated %s by %s, oldid %s using popups'; popupQueriedRevertToPreviousSummary = 'Revert to the revision prior to revision $1 dated $2 by $3 using popups'; popupRevertToPreviousSummary = 'Revert to the revision prior to revision %s using popups'; popupRevertSummaryPrompt = true; popupStructure = 'menus'; popupFixDabs = 'true'; popupFixDabsSummary = 'Disambiguate %s to %s using popups'; popupRmDabLinkSummary = 'Remove link to dab page %s using popups'; // END Adds NavigationPopups // install User:Cacycle/wikEdDiff enhanced diff importScriptURI('//en.wikipedia.org/w/index.php?title=User:Cacycle/wikEdDiff.js&action=raw&ctype=text/javascript');
 * (function($, mw) {

if(window.location.pathname.indexOf('Special:InfoboxBuilder') != -1) { var pname = window.location.pathname.split('Special:InfoboxBuilder/')[1]; location.replace(document.URL.replace(window.location.href.split('/wiki/')[1], 'Template:' + pname + '?action=edit&useeditor=source')); }

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:WorkingMoreUsersCount.js'    ] });

// Add wgWikiName variable to mw.config // By User:Colouratura mw.config.values[ 'wgWikiName' ] = function { return window.location.toString.split( '.wikia.com' )[ 0 ].slice( 7 ); };

// Load the following code on vstf.wikia.com and communitycouncil.wikia.com only if (['vstf', 'communitycouncil'].includes(mw.config.get('wgWikiName'))) { importArticles({   type: 'script',    articles: [        'u:dev:SeeMoreActivityButton/code.js',        'u:dev:AjaxRC/code.js',    ]  });

;(function {   if (navLinks) return;    var user = mw.util.wikiUrlencode(mw.config.get('wgUserName')),        links = {          contribs: {            text: 'My Contributions',            url: '/wiki/Special:Mycontributions'          },          blogs: {            text: 'My Blogs',            url: '/wiki/User_blog:' + user          },          watchlist: {            text: 'My Watchlist',            url: '/wiki/Special:Watchlist'          },          followed: {            text: 'My Followed Pages',            url: '/wiki/Special:Following'          }      },      html = '',      navLinks = true;    for (var i in links) {      html += '<li><a href="' + links[i].url + '" class="wds-global-navigation__dropdown-link">' + links[i].text + '</a></li>';    }    document.querySelector('.wds-global-navigation__user-menu .wds-list > li:nth-child(2)').insertAdjacentHTML('afterEnd', html);  }); }