Jump to content

User:RexxS/common.js

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
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.
// User:Zhaofeng Li/reFill - was Reflinks
mw.loader.load( "https://meta.wikimedia.org/w/index.php?title=User:Zhaofeng_Li/Reflinks.js&action=raw&ctype=text/javascript" );
// end

/**
 * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
 * @see https://meta.wikimedia.org/wiki/TemplateScript
 * @update-token [[File:Pathoschild/templatescript.js]]
 */
// mw.loader.load('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js');

/** This script contains the code required for loading [[User:Joeytje50/AWB.js]].
 *  All other code is located at that page.
 */

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

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');
*/

/***********************************************************
 * Refresh Category
 * 
 * found during a discusion - can't remember the author
 * quote = Of course. We have a button in "more" menu on category pages, "refresh". Clicking on it makes forceupdate nulledit on all pages in this category. Interested?
 * 
 **********************************************************/
mw.loader.using( [ 'mediawiki.util', 'mediawiki.api' ] ).then( function() {
	var step = 10;
	var count;
	var wait;
	function postPurge(cat, addParams) {
		var apiParams = $.extend({
			action: 'purge', 
			generator: 'categorymembers',
  			'gcmtitle': cat,
  			'gcmlimit': step,
			forcelinkupdate: 1
		}, addParams);
		new mw.Api().post(apiParams)
			.fail(function() {
				alert("Fail");
			})
			.done(function(d) {
			console.log(d);
			count += step;
			if (d.warnings === undefined && d["continue"] !== undefined
					&& d["continue"].gcmcontinue) {
				mw.notify(count + " pages were updated");
				setTimeout(function() {
						postPurge(cat, d["continue"]);
					}, wait);
			} else {
				alert("Done!");
				document.location.reload();
		}});
	}
	if (mw.config.get('wgNamespaceNumber') == 14) {
		wait = 1000;
		new mw.Api().get({
    		meta: 'userinfo',
    		uiprop: 'ratelimits'
		}).done(function(d) {
			if (d && d.query && d.query.userinfo && d.query.userinfo.ratelimits
    				&& d.query.userinfo.ratelimits.purge)
				wait = 2000;
				$(mw.util.addPortletLink('p-cactions', '#', 'refresh', 'pt-refresh'))
					.click(function() {
						count = 0;
						postPurge(mw.config.get('wgPageName')
							.replace(/_/g, " "));
					});
		} );
	}
});

$(document).ready( function() {
	var desktopLink = document.getElementById("mw-mf-display-toggle");
	if (desktopLink === null) {
		return;
	}
	var href = desktopLink.getAttribute('href');
	if (href.indexOf('.m.') > -1) {
		return;
	}
	// You can use .assign() instead, if you want to
	// keep the URL of the mobile site in your history.
	window.location.replace(href);
} );

/* show LintErrors analysis (Parsoid messages) live - User:PerfektesChaos/js/lintHint */
mw.loader.load( "https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/lintHint/r.js&action=raw&bcache=1&maxage=86400&ctype=text/javascript" );

importScript('User:Ucucha/HarvErrors.js');

importScript('User:Frietjes/infoboxgap.js'); // [https://en.wikipedia.org/w/index.php?title=User:Frietjes/infoboxgap]

importScript( 'User:Amorymeltzer/crathighlighter.js' ); // Backlink:User:Amorymeltzer/crathighlighter.js

importScript('User:Ohconfucius/script/MOSNUM dates.js'); // [[User:Ohconfucius/script/MOSNUM dates.js]]

importScript( 'User:Kaniivel/RefConsolidate_start.js' ); // https://en.wikipedia.org/w/index.php?title=User:Kaniivel/Reference_Organizer