User:Celeste/common.js

// Highlight admins $.getJSON(mw.config.get('wgScriptPath')+'/index.php?action=raw&ctype=application/json&title=User:Amalthea_(bot)/userhighlighter.js/sysop.js', function(data){		ADMINHIGHLIGHT_EXTLINKS = window.ADMINHIGHLIGHT_EXTLINKS || false;		ADMINHIGHLIGHT_NAMESPACES = [-1,2,3];		mw.loader.using(['mediawiki.util','mediawiki.Uri', 'mediawiki.Title'], function { mw.util.addCSS(".userhighlighter_sysop.userhighlighter_sysop {background-color: #00FFFF !important}"); $('#bodyContent a').each(function(index,linkraw){				try {					var link = $(linkraw);					var url = link.attr('href');					if (!url || url.charAt(0) === '#') return; // Skip  elements that aren't actually links; skip anchors					if (url.lastIndexOf("http://", 0) != 0 && url.lastIndexOf("https://", 0) != 0 && url.lastIndexOf("/", 0) != 0) return; //require http(s) links, avoid "javascript:..." etc. which mw.Uri does not support					var uri = new mw.Uri(url);					if (!ADMINHIGHLIGHT_EXTLINKS && !$.isEmptyObject(uri.query)) return; // Skip links with query strings if highlighting external links is disabled					if (uri.host == 'en.wikipedia.org') {						var mwtitle = new mw.Title(mw.util.getParamValue('title',url) || decodeURIComponent(uri.path.slice(6))); // Try to get the title parameter of URL; if not available, remove '/wiki/' and use that						if ($.inArray(mwtitle.getNamespaceId, ADMINHIGHLIGHT_NAMESPACES)>=0) { var user = mwtitle.getMain.replace(/_/g," "); if (mwtitle.getNamespaceId === -1) user = user.replace('Contributions/',''); // For special page "Contributions/ " if (data[user] == 1) { link.addClass('userhighlighter_sysop'); // Override the above color by using `a.userhighlighter_sysop.userhighlighter_sysop {background-color: COLOR !important}` }						}					}				} catch (e) { // Sometimes we will run into unparsable links, so just log these and move on					window.console && console.error('Admin highlighter recoverable error',e.message); }			});		});	}); }(jQuery, mediaWiki));
 * (function($, mw){

// js chicken highlight

function Hilitor(id, tag) {

// private variables var targetNode = document.getElementById(id) || document.body; var hiliteTag = tag || "MARK"; var skipTags = new RegExp("^(?:" + hiliteTag + "|SCRIPT|FORM|SPAN)$"); var colors = ["#ff6"]; var wordColor = []; var colorIdx = 0; var matchRegExp = ""; var openLeft = false; var openRight = false;

// characters to strip from start and end of the input string var endRegExp = new RegExp('^[^\\w]+|[^\\w]+$', "g");

// characters used to break up the input string into words var breakRegExp = new RegExp('[^\\w\'-]+', "g");

this.setEndRegExp = function(regex) { endRegExp = regex; return endRegExp; };

this.setBreakRegExp = function(regex) { breakRegExp = regex; return breakRegExp; };

this.setMatchType = function(type) {   switch(type) {     case "left": this.openLeft = false; this.openRight = true; break;

case "right": this.openLeft = true; this.openRight = false; break;

case "open": this.openLeft = this.openRight = true; break;

default: this.openLeft = this.openRight = false;

} };

this.setRegex = function(input) {   input = input.replace(endRegExp, ""); input = input.replace(breakRegExp, "|"); input = input.replace(/^\||\|$/g, ""); if(input) { var re = "(" + input + ")"; if(!this.openLeft) re = "\\b" + re; if(!this.openRight) re = re + "\\b"; matchRegExp = new RegExp(re, "i"); return matchRegExp; }   return false; };

this.getRegex = function {   var retval = matchRegExp.toString; retval = retval.replace(/(^\/(\\b)?|\(|\)|(\\b)?\/i$)/g, ""); retval = retval.replace(/\|/g, " "); return retval; };

// recursively apply word highlighting this.hiliteWords = function(node) {   if(node === undefined || !node) return; if(!matchRegExp) return; if(skipTags.test(node.nodeName)) return;

if(node.hasChildNodes) { for(var i=0; i < node.childNodes.length; i++) this.hiliteWords(node.childNodes[i]); }   if(node.nodeType == 3) { // NODE_TEXT if((nv = node.nodeValue) && (regs = matchRegExp.exec(nv))) { if(!wordColor[regs[0].toLowerCase]) { wordColor[regs[0].toLowerCase] = colors[colorIdx++ % colors.length]; }

var match = document.createElement(hiliteTag); match.appendChild(document.createTextNode(regs[0])); match.style.backgroundColor = wordColor[regs[0].toLowerCase]; match.style.color = "#000";

var after = node.splitText(regs.index); after.nodeValue = after.nodeValue.substring(regs[0].length); node.parentNode.insertBefore(match, after); }   };  };

// remove highlighting this.remove = function {   var arr = document.getElementsByTagName(hiliteTag); while(arr.length && (el = arr[0])) { var parent = el.parentNode; parent.replaceChild(el.firstChild, el); parent.normalize; } };

// start highlighting at target node this.apply = function(input) {   this.remove; if(input === undefined || !input) return; if(this.setRegex(input)) { this.hiliteWords(targetNode); }   return matchRegExp; };

}

var myHilitor = new Hilitor("content"); // id of the element to parse myHilitor.apply("chicken chickens");

// Zombiebaron scripts

mw.loader.load("//en.uncyclopedia.co/w/index.php?title=User:Zombiebaron/SkinSwitcher.js&action=raw&ctype=text/javascript"); //Skin switcher (Based on the original script by Wikipedia:User:Eizzen)

mw.loader.load('//en.uncyclopedia.co/w/index.php?title=User:Zombiebaron/Invert.js&action=raw&ctype=text/javascript'); //Night mode (Based on the Invert script by Wikipedia:User:BrandonXLF)

mw.loader.load("//en.wikipedia.org/w/index.php?title=User:Animum/massdelete.js&action=raw&ctype=text/javascript"); //Mass delete

mw.loader.load("//en.wikipedia.org/w/index.php?title=User:Writ Keeper/Scripts/googleTitle.js&action=raw&ctype=text/javascript"); //Google title

mw.loader.load("//en.wikipedia.org/w/index.php?title=User:Sam Sailor/Scripts/WRStitle.js&action=raw&ctype=text/javascript"); //Wikipedia Reference Search title

mw.loader.load("//en.wikipedia.org/w/index.php?title=User:SoledadKabocha/copySectionLink.js&action=raw&ctype=text/javascript"); //Copy Section Link

mw.loader.load("//en.wikipedia.org/w/index.php?title=User:DannyS712/Readonly.js&action=raw&ctype=text/javascript"); //Forced view source

mw.loader.load("//en.wikipedia.org/w/index.php?title=User:Begoon/addUploadsLink.js&action=raw&ctype=text/javascript"); //User uploads

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:SoledadKabocha/enterInSummaryPreviews.js&action=raw&ctype=text/javascript'); //Pressing enter in the edit summary box takes you to edit preview

mw.loader.load('//de.wikipedia.org/w/index.php?title=Benutzer:TMg/autoFormatter.js&action=raw&ctype=text/javascript'); //Auto Formatter

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Joeytje50/JWB.js/load.js&action=raw&ctype=text/javascript'); //Javascript Wiki Browser

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Eizzen/PageCreator.js&action=raw&ctype=text/javascript'); //Page Creator - currently only in mainspace

mw.loader.load("//en.wikipedia.org/w/index.php?title=User:Eizzen/LastEditor.js&action=raw&ctype=text/javascript"); //Last Editor - currently only in mainspace

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Dudemanfellabra/diffs.js&action=raw&ctype=text/javascript'); //adds time between diffs and time since each revision

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Equazcion/link intermediate revisions.js&action=raw&ctype=text/javascript'); //link intermediate revisions

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Writ Keeper/Scripts/commonHistory.js&action=raw&ctype=text/javascript'); //View diffs on Recent Changes

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Jfmantis/pagesCreated.js&action=raw&ctype=text/javascript'); //Pages created

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Fred Gandt/responsiveHistoryCompare.js&action=raw&ctype=text/javascript'); //dynamically moves Compare selected revisions button

popupStructure = 'menus';

/* Rollback all */ $( function {	if ( $('span.mw-rollback-link')[0] && mw.config.get( 'wgCanonicalSpecialPageName' ) == 'Contributions' )		mw.util.addPortletLink( 'p-cactions', 'javascript:rollbackEverything', "rollback all", "ca-rollbackeverything", "Rollback all top edits displayed here" ); } ); function rollbackEverything { for ( var i in document.links ) { if ( document.links[i].href.indexOf( 'action=rollback' ) != -1 ) window.open( document.links[i].href+'&bot=1' ); } }

/* Interface modifications */

$( function{

// These add action tabs at the top of a page

if( mw.config.get( 'wgNamespaceNumber' ) > -1 ) { mw.util.addPortletLink( 'p-cactions', '/wiki/Special:PrefixIndex/' + wgPageName, 'Subpages', 'd-subpages', 'List subpages and other pages starting with this title' ); mw.util.addPortletLink( 'p-cactions', '/w/index.php?title=Special:Log&page=' + wgPageName, 'Logs', 'd-logs', 'Show any relevant logs for this title' ); mw.util.addPortletLink( 'p-cactions', '/wiki/' + wgPageName + '?action=purge', 'Purge', 'd-purge', 'Purge the current page' ); // 		mw.util.addPortletLink( 'p-cactions', '/wiki/' + wgPageName + '?useskin=vector', 'Vector', 'd-vector', 'View page in the Vector skin' ); }

// These add personal links at the top right of every page

mw.util.addPortletLink( 'p-personal', '/wiki/Special:ListFiles/' + wgUserName, 'Uploads', 'pt-uploads' ); mw.util.addPortletLink( 'p-personal', '/wiki/Special:Log/' + wgUserName, 'Logs', 'pt-logs' ); mw.util.addPortletLink( 'p-personal', '/wiki/Special:PrefixIndex/User:'+ wgUserName, 'Subpages', 'pt-subpages' );

$("#pt-logout").hide;

// These add toolbox links to the sidebar of every page

mw.util.addPortletLink( 'p-tb', 'https://en.uncyclopedia.co/wiki/User:Zombiebaron/2019.js', '2019.js Project', 't-2019' ); mw.util.addPortletLink( 'p-tb', 'https://en.uncyclopedia.co/wiki/User:Zombiebaron/Images', 'Images', 't-images' ); mw.util.addPortletLink( 'p-tb', 'https://en.uncyclopedia.co/wiki/Special:MassDelete', 'mass delete', 't-massdelete' );

$('#n-currentevents').after($('#n-recentchanges')); $('#n-recentchanges').css({ 'font-weight': 'bold' });

} );

/* Edit counter in top bar - by Wikipedia:User:Mvolz */

$(document).ready( function { 	mw.loader.using( 'mediawiki.user', function { ( new mw.Api ).get( {	       action: 'query',	        meta: 'userinfo',	        uiprop: 'editcount'	    } ).done( function( result ) {	    	document.getElementById( 'pt-mycontris' ).append( ' (' + result.query.userinfo.editcount + ')' );	    } ); } ); } );

// Other scripts

// mw.loader.load('//en.uncyclopedia.co/w/index.php?title=User:JJPMaster/CurateThisPage2.js&action=raw&ctype=text/javascript'); // mw.loader.load('//en.uncyclopedia.co/w/index.php?title=User:JJPMaster/userinfo.js&action=raw&ctype=text/javascript');