Note – after saving, you may have to bypass your browser’s cache to see the changes.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

This JavaScript is executed for Surjection on every page load.


window.defaultVisibilityTogglesForUsageExamples = true;

jQuery(document).ready(function($){
	console.log("executing common.js");
	
	try {
		/********* streamline *********/
		mw.loader.load('//en.wiktionary.org/w/index.php?title=User:Surjection/streamline.js&action=raw&ctype=text/javascript');
		
		/********* HotCat test env *********/
		mw.loader.load('//en.wiktionary.org/w/index.php?title=User:Surjection/HotCat-dev.js&action=raw&ctype=text/javascript');
		
		/********* Visibility toggles *********/
		// mw.loader.load('//en.wiktionary.org/w/index.php?title=User:Surjection/Gadget-defaultVisibilityToggles.js&action=raw&ctype=text/javascript');
		
		/********* link language headers *********/
		// mw.loader.load('//en.wiktionary.org/w/index.php?title=User:Surjection/linkLanguageHeaders.js&action=raw&ctype=text/javascript');
		
		/********* TOC column *********/
		// mw.loader.load('//en.wiktionary.org/w/index.php?title=User:Surjection/tocColumn.js&action=raw&ctype=text/javascript');
		
		/********* rollback msg *********/
		$('span.mw-rollback-link a').each(function(){if(-~this.href.indexOf('&action=rollback&')&&this.href.indexOf('summary=')<0)this.href+='&summary=Reverted%20edits%20by%20%5B%5BSpecial%3AContributions%2F%242%7C%242%5D%5D.%20If%20you%20think%20this%20rollback%20is%20in%20error%2C%20please%20leave%20a%20message%20on%20my%20%5B%5BUser%20talk%3ASurjection%7Ctalk%20page%5D%5D.'});
	
		/********* silent rb *********/
		mw.hook("wikipage.content").add(function() {
			setTimeout(function() {
				if ($('span.mw-rollback-link a').length) {
					$('#surjection-t-rb-lta').remove();
					$('#p-tb ul').append('<li id="surjection-t-rb-lta" class="mw-list-item"><a href="javascript:void(0)" id="surjection-t-rb-lta-link">Hide RB msgs</a></li>');
					$('#surjection-t-rb-lta-link').click(function(){
						$('span.mw-rollback-link a').each(function(){if(-~this.href.indexOf('&action=rollback&')){
							if(this.href.indexOf('summary=')>=0)
								this.href=this.href.split('&summary=')[0];
							this.href+='&summary=rv%2Fv';
						}});
						$('#surjection-t-rb-lta-link').text('RB messages hidden!');
					});
				}
			}, 250);
		});
		
		/********* mass revdel *********/
		mw.loader.load('//en.wiktionary.org/w/index.php?title=User:Surjection/massRevdel.js&action=raw&ctype=text/javascript');
		
		/********* mass rv *********/
		{
			var nukeLink = $('.mw-changeslist-links .mw-contributions-link-nuke');
			if (nukeLink) {
				var linkSpan = nukeLink.parent();
				var rv = $('<a href="#">mass revert</a>');
				rv.click(function(e) {
					if (confirm('Are you sure?')) {
						$('.mw-contributions-current span.mw-rollback-link a').each(function() {
							if(-~this.href.indexOf('&action=rollback&')){
								window.open(this.href, '_blank');
							}
						});
						alert("OK");
					}
				});
				$('<span></span>').append(rv).insertAfter(linkSpan);
			}
		}
		
		/********* quick move revert *********/
		$('.mw-logline-move a[href*="wpReason=revert"]').each(function() {
			if (this.href.indexOf('&autosubmitmove=1') < 0) 
				this.href += '&wpLeaveRedirect=0&autosubmitmove=1';
		});
		if (mw.config.get("wgPageName").startsWith("Special:MovePage") && new URL(window.location.href).searchParams.get("autosubmitmove") == '1') {
			$('button[name="wpMove"]').click();
		}
		
		/********* quick LTA block *********/
		var ltaBlockLink = '/wiki/Special:Block/@@@?wpCreateAccount=1&wpDisableUTEdit=1&wpExpiry=indefinite&wpHardBlock=1&wpReason=Vandalism&wpReason-other=LTA&wpDisableEmail=1&autosubmitblock=0';
		var spamBlockLink = '/wiki/Special:Block/@@@?wpCreateAccount=1&wpDisableUTEdit=1&wpExpiry=indefinite&wpHardBlock=1&wpReason=Promotional%20material%2Fspamming&wpDisableEmail=1&autosubmitblock=0';
		var spamIpBlockLink = '/wiki/Special:Block/@@@?wpCreateAccount=1&wpExpiry=6+months&wpReason=Promotional%20material%2Fspamming&autosubmitblock=0';
		var proxyBlockLink = '/wiki/Special:Block/@@@?wpCreateAccount=1&wpDisableUTEdit=1&wpExpiry=6+months&wpHardBlock=1&wpReason=Suspected+%5B%5BWiktionary%3AProject+-+Open+proxies%7Copen+proxy%5D%5D&autosubmitblock=0';
		var botBlockLink = '/wiki/Special:Block/@@@?wpCreateAccount=1&wpDisableUTEdit=1&wpExpiry=indefinite&wpHardBlock=1&wpReason=Unauthorized+bot+%28see+%5B%5BWT%3ABOT%5D%5D%29&wpDisableEmail=1&autosubmitblock=0';
		var hiddenBlockLink = '/wiki/Special:Block/@@@?wpCreateAccount=1&wpDisableUTEdit=1&wpExpiry=indefinite&wpHardBlock=1&wpDisableEmail=1&autosubmitblock=0';
		var sleeperBlockLink = '/wiki/Special:Block/@@@?wpCreateAccount=1&wpExpiry=indefinite&wpHardBlock=1&wpReason=Abusing+multiple+accounts%2Fblock+evasion&wpDisableEmail=1&autosubmitblock=0';
		if (mw.config.get("wgPageName").startsWith("Special:Contributions/")) {
			var isIP = !Array.prototype.find.call(document.querySelector(".mw-contributions-user-tools").getElementsByTagName("a"),function(a){return (a.getAttribute("title") || '').slice(0,5) == "User:"});
			var buttons = isIP ? [["proxy block", proxyBlockLink], ["spam block", spamIpBlockLink]] : [["sleeper block", sleeperBlockLink], ["LTA block", ltaBlockLink], ["stealth block", hiddenBlockLink], ["spam block", spamBlockLink], ["bot block", botBlockLink]];
			var pn = mw.config.get("wgPageName");
			var usern = pn.slice(pn.indexOf("/") + 1);
			var makeLink = function(url) { return url.replace("@@@", encodeURIComponent(usern)); };
			buttons.forEach(function(button) {
				$('#contentSub a[href*="Special:Block/"]').first().after(' | <a href="'+makeLink(button[1])+'">(' + button[0] + ')</a>');
			});
		}
		if (mw.config.get("wgPageName").startsWith("Special:Block/") && new URL(window.location.href).searchParams.get("autosubmitblock") == '1') {
			$('button[value="Block this user"]').click();
		}
		
		/********* block IPv6 /64 by default *********/
		if (mw.config.get("wgPageName").startsWith("Special:Contributions/") || mw.config.get("wgDiffNewId")) {
			var blockIPv6 = /Special:Block\/[0-9A-Fa-f]{0,4}:[0-9A-Fa-f]{0,4}:[0-9A-Fa-f]{0,4}:[0-9A-Fa-f]{0,4}:[0-9A-Fa-f]{0,4}:[0-9A-Fa-f]{0,4}:[0-9A-Fa-f]{0,4}:[0-9A-Fa-f]{1,4}$/;
			$('a[href*="/Special:Block/"]').each(function(i, element) {
				element.href = element.href.replace(blockIPv6, function (m) { return m + "/64"; });
			});
		}
		
		/********* autofeed *********/
		if (mw.config.get('wgAction') == 'edit' && new URLSearchParams(document.location.search).has('autofeedtext')) {
			var editField = $('#wpTextbox1');
			if (editField.val()) {
				var newtext = document.createElement('textarea');
				newtext.setAttribute('readonly', true);
				newtext.setAttribute('rows', 20);
				newtext.textContent = new URLSearchParams(document.location.search).get('autofeedtext');
				document.getElementById('mw-content-text').insertBefore(newtext, document.getElementById('editform'));
			} else {
				editField.val(new URLSearchParams(document.location.search).get('autofeedtext'));
			}
		}
	} catch (e) {
		console.error(e);
	}
	
	mw.hook("wikipage.content").add(function() { console.log("wikipage.content hook"); });
	
	console.log("executed common.js");
});