Jump to content

User:SkyWarrior/common.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by SkyWarrior (talk | contribs) at 03:57, 14 November 2017. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
// Following script is broken
// importScript('User:Fox Wilson/delsort.js'); // Deletion sorting script [[WP:FWDS]]
importScript('User:Enterprisey/delsort.js');

/** This script contains the code required for loading [[User:Joeytje50/AWB.js]].
 *  All other code is located at that page.
 */
mw.loader.using( 'mediawiki.util', function() {
	if (mw.config.get('wgCanonicalNamespace')+':'+mw.config.get('wgTitle') === 'Project:AutoWikiBrowser/Script')
		mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Joeytje50/JWB.js&action=raw&ctype=text/javascript');
	importScript( 'User:Andy M. Wang/pageswap.js' ); // Backlink: [[User:Andy M. Wang/pageswap]]

	//Idea by [[User:Epicgenius]]
	$( function() {
		mw.util.addPortletLink("p-tb", mw.config.get('wgArticlePath').replace('$1', "Project:AutoWikiBrowser/Script"), "JS Wiki Browser", "tb-awbscript", "Run Javascript Wiki Browser");
	} );
} );
importScript('User:Jackmcbarn/editProtectedHelper.js'); // Linkback: [[User:Jackmcbarn/editProtectedHelper.js]]

/* This script adds the Page Curation link to the top toolbar; the link combines the two main Page Curation
   features, namely the Special:NewPagesFeed and the curation toolbar. It is primarily designed to
   assist new page reviewers. Page Curation is a feature-rich purpose-built system to review new pages.
   Be sure to have read and fully understood the instructions at New Pages Patrol. To use the script,
   add the following line to Special:MyPage/common.js:
 
importScript('User:Lourdes/PageCuration.js'); // Linkback: [[User:Lourdes/PageCuration.js]]

*/
 
$.when( mw.loader.using( ['mediawiki.util'] ), $.ready ).done( function() {
  mw.util.addPortletLink(
    'p-personal',
    mw.util.getUrl('Special:NewPagesFeed'),
    'Page Curation',
    'pt-pagecuration',
    'View Special:New Pages using the Page Curation tool',
    null,
    '#pt-preferences'
  );
});

//Mass rollback function
//Written by John254 and modified/rewritten by Writ Keeper with modifications by TheDJ; original is at https://en.wikipedia.org/wiki/User:John254/mass_rollback.js
//Adapted from User:Mr.Z-man/rollbackSummary.js
//Instructions: Selecting the "rollback all" tab when viewing a user's contributions history
//will open all rollback links displayed there. (Use with caution)
  
function rollbackEverythingWKMR(editSummary) 
{
	if(editSummary === null)
	{
		return false;
	}
	var userName = mw.config.get("wgRelevantUserName");
	var titleRegex = /title=([^&]+)/;
	
	mw.loader.using( 'mediawiki.api.rollback' ).done( function()
	{
		var api = new mw.Api();
		
		$("a[href*='action=rollback']").each(function(ind, el)
		{
			var params = {};
			if( editSummary != '' )
			{
				params.summary = editSummary;
			}
			api.rollback( decodeURIComponent(titleRegex.exec(el.href)[1]), userName, params).done( function()
			{
				$(el).after("reverted");
				$(el).remove();
			} );
		} );
	} );
	return false;
}
$(document).ready(function()
{
	if(mw.config.get("wgCanonicalSpecialPageName") == "Contributions" && $("span.mw-rollback-link").length > 0)
	{
		mw.loader.using("mediawiki.util").done( function ()
		{
			mw.util.addPortletLink('p-cactions', '#', "rollback all", "ca-rollbackeverything", "rollback all edits displayed here");
			$("#ca-rollbackeverything").click( function(event)
			{
				event.preventDefault();
				mw.loader.load( [ 'mediawiki.api.rollback' ] ); //start loading, while the user is in the prompt
				return rollbackEverythingWKMR(prompt("Enter an edit summary, or leave blank to use the default (or hit Cancel to cancel the rollback entirely)"));
			});
		});
	}
});