User:Tripleahg/vector.js

// // pageCollector.js see https://en.wikipedia.org/wiki/User:%D7%A7%D7%99%D7%A4%D7%95%D7%93%D7%A0%D7%97%D7%A9/pageCollector // can be set up to add things to to-do lists (function {   function save(title, content, next)	{		var param = {action: 'edit', title: title, summary: 'adding ' + content, token: mw.user.tokens.get('csrfToken'), appendtext: content, format: 'json'};		$.post(mw.util.wikiScript('api'), param, function { mw.util.jsMessage(content + ' added to page ' + title); }); //flying blind	}	function add_button(page, caption)	{		var addColon = $.inArray(mw.config.get('wgNamespaceNumber'), [6,14]) + 1; //file:, category:		var pageName = (addColon ? ":" : "") + wgPageName.replace( /_/g, " " );		var text =  + pageName + ;		var a = mw.util.addPortletLink(window.pageCollectorMenu || 'p-cactions','#',caption,'','add this page to: "' + page + '"');		$(a).click(function {save(page, '\n* ' + text);});	}    $(window.pagesToCollect).each(function {add_button(this.page, this.caption);}); });

//Original file location http://en.wikipedia.org/wiki/User:JeremyMcCracken/contribstab.js addOnloadHook(contribstab); //means «execute func_start later» function contribstab { if (wgNamespaceNumber == 2 || wgNamespaceNumber == 3) { //If we're in User or User talk namespace var pagename; var name1; var name2; name1=wgPageName.indexOf(":"); //Find the colon to separate User: prefix if (name1 != -1) { //Skip it if we didn't find a colon name1=name1+1; pagename=wgPageName.substring(name1); } else { pagename=wgPageName; //if no colon, assume we have the user name already } name2=pagename.indexOf("/"); //If it's a subpage, get root name if (name2 > 0){ //if we found a slash earlier pagename=pagename.substring(0,name2); } addPortletLink ('p-cactions', '/wiki/Special:Contributions/'+pagename, 'Contributions', 1, 'View this user\'s contributions'); //Add the button } //resumes here for non-user/UT pages }

// https://en.wikipedia.org/wiki/User:Equazcion/ReverseMarked.js if (wgPageName == "Special:Watchlist") { $('table.mw-changeslist-line-not-watched').find('td:gt(0)').css('opacity', '0.8'); $('table.mw-changeslist-line-not-watched').find('a:first').css('opacity', '0.68').css('font-style','italic').css('font-size','98%'); $('table.mw-changeslist-line-watched').find('a:first').css('opacity', '1').css('font-style','normal').css('font-size','100%'); $('table.mw-changeslist-line-watched').find('td:gt(0)').css('opacity', '1').css('font-style','normal').css('font-size','100%'); $('li.mw-changeslist-line-not-watched').css('opacity', '0.8'); $('li.mw-changeslist-line-not-watched').css('opacity', '0.68').css('font-style','italic').css('font-size','98%'); $('li.mw-changeslist-line-watched').css('opacity', '1').css('font-style','normal').css('font-size','100%'); $('li.mw-changeslist-line-watched').css('opacity', '1').css('font-style','normal').css('font-size','100%'); $('#mw-watchlist-resetbutton').remove; } if (wgAction == "history") { // Green "updated since my last visit" notices are also not conducive to this setup, // since we're now trying to "demote" checked changes rather than highlight unchecked ones. $('.updatedmarker').remove; }

// https://en.wikipedia.org/wiki/User:Dr_pda/editrefs.js //This function adds a link to the toolbox which, when clicked, searches the article for //tags and presents them in textboxes for ease of editing //To use this function add importScript('User:Dr pda/editrefs.js'); //User:Dr pda/editrefs.js to your monobook.js // function editRefs{ //Hide edit window var editform = document.getElementById('editform'); editform.style.cssText += 'display:none'; text = document.getElementById('wpTextbox1').value; //Hack to cope with HTML comments text = text.replace(/-->/g,"--@#%"); // var refs = text.match(/|/g); refs = text.match(/<[Rr]ef(\s*name=[^\>]*)?>[^>]*<\/[Rr]ef>/g); text = text.replace(/--@#%/g,"-->"); var output = document.createElement("ol"); output.id = 'ref-edit-ol'; if(refs != null){ for (x=0; x"); var ref_textbox = document.createElement("textarea"); ref_textbox.id = 'ref-box-'+x; var ref_li = document.createElement("li"); ref_li.id = 'ref-li-'+x; ref_textbox.value = refs[x]; var newlines = refs[x].match(/\n/g); var lines = (newlines == null) ? 1 : newlines.length+1; ref_textbox.rows = (lines > refs[x].length/70) ? lines : refs[x].length/70; ref_textbox.cols = 70; ref_textbox.style.cssText = 'display:block;'; ref_li.appendChild(ref_textbox); output.appendChild(ref_li); } }  else{ var ref_li = document.createElement("li"); ref_li.id = 'ref-li'; ref_li.innerHTML = 'This article contains no &lt;ref&gt;&lt;/ref&gt; tags'; output.appendChild(ref_li); } var dummy = document.getElementById("editform"); dummy.parentNode.insertBefore(output, dummy); //Add buttons var update = document.createElement("input"); update.id = 'ref-edit-update'; update.value = 'Apply changes and preview'; update.title = 'Apply changes and preview'; update.type = 'button'; update.onclick = updateRefs; var cancel = document.createElement("input"); cancel.id = 'ref-edit-cancel'; cancel.value = 'Cancel and return to edit'; cancel.title = 'Cancel and return to edit'; cancel.type = 'button'; cancel.onclick = returnToEdit; var reset = document.createElement("input"); reset.id = 'ref-edit-reset'; reset.value = 'Reset fields'; reset.title = 'Reset fields'; reset.type = 'button'; reset.onclick = resetRefs; if(refs != null){ output.parentNode.insertBefore(update, output.nextSibling); update.parentNode.insertBefore(cancel, update.nextSibling); cancel.parentNode.insertBefore(reset, cancel.nextSibling); } else{ output.parentNode.insertBefore(cancel, output.nextSibling); } } function updateRefs{ var startIndex = -1; for (x=0; x<refs.length;x++){ var newref = document.getElementById('ref-box-'+x).value; startIndex = text.indexOf(refs[x],startIndex); //Only update if changed if(refs[x] != newref){ text = text.substring(-1,startIndex) + newref + text.substring(startIndex + refs[x].length); }   startIndex = startIndex + newref.length; } var textbox = document.getElementById('wpTextbox1'); textbox.value = text; //returnToEdit; document.getElementById('wpPreview').click; } function returnToEdit{ //Hide textboxes and buttons var output = document.getElementById('ref-edit-ol'); output.parentNode.removeChild(output); var update = document.getElementById('ref-edit-update'); if(update) update.parentNode.removeChild(update); var cancel = document.getElementById('ref-edit-cancel'); if(cancel) cancel.parentNode.removeChild(cancel); var reset = document.getElementById('ref-edit-reset'); if(reset) reset.parentNode.removeChild(reset); //Show edit window var editform = document.getElementById('editform'); editform.style.cssText = ''; } function resetRefs{ for (x=0; x<refs.length;x++){ var ref_textbox = document.getElementById('ref-box-'+x); ref_textbox.value = refs[x]; } } addOnloadHook(function {   if(document.forms.editform){     mw.util.addPortletLink('p-tb', 'javascript:editRefs', 'Edit references', 't-edit-refs', 'Edit tags', , );   } }); // https://en.wikipedia.org/wiki/User:PrimeHunter/My_subpages.js /* This script adds a link saying "Subpages" to subpages of your user page. To use the script, add the following line to Special:MyPage/common.js: importScript('User:PrimeHunter/My_subpages.js'); // Linkback: User:PrimeHunter/My subpages.js $( document ).ready( function { mw.util.addPortletLink( 'p-personal', mw.util.getUrl( 'Special:PrefixIndex/User:' ) + mw.config.get( 'wgUserName' ) + '/', 'Subpages', 'pt-mysubpages', 'Show your subpages', null, '#pt-preferences' ); });

// https://en.wikipedia.org/wiki/User:Writ_Keeper/Scripts/deletionFinder.js $(document).ready(deletionChecker); encodedTitle = encodeURIComponent(mw.config.get('wgPageName')); function deletionChecker {	var encodedTitle = encodeURIComponent(mw.config.get('wgPageName')); var delRequest = $.get("/w/api.php?action=query&list=logevents&format=json&leprop=ids&letype=delete&letitle=" + encodedTitle + "&lelimit=1", null, delCallback, "json"); if(wgCanonicalNamespace == "") {		var afdRequest = $.get("/w/api.php?action=query&list=allpages&format=json&apfrom=Articles%20for%20deletion%2F" + encodedTitle + "&apto=Articles%20for%20deletion%2F" + encodedTitle + "&apnamespace=4&aplimit=1", null, afdCallback, "json"); } } function delCallback(delResults) {	if(delResults.query.logevents[0] != null) {			var searchNode = document.createElement("a"); searchNode.href = wgServer + "/w/index.php?title=Special%3ALog&type=delete&page=" + encodedTitle; searchNode.target = "_blank"; searchNode.innerHTML = " prev dels "; document.getElementById("firstHeading").appendChild(searchNode); } } function afdCallback(afdResults) {	if(afdResults.query.allpages[0] != null) {		var searchNode = document.createElement("a"); searchNode.href = wgServer + "/w/index.php?title=Special%3AAllPages&from=Articles+for+deletion%2F" + encodedTitle + "&to=Articles+for+deletion%2F" + encodedTitle + "+%289z%29&namespace=4"; searchNode.target = "_blank"; searchNode.innerHTML = " prev AfDs "; document.getElementById("firstHeading").appendChild(searchNode); } }

// https://en.wikipedia.org/wiki/User:PleaseStand/highlight-comments.js /** * Highlights specific users' posts to discussion pages using a CSS class. * * Originally written by PleaseStand in 2010, updated for MediaWiki 1.17 in 2011 * Rewrite completed in 2012 * * Released to the public domain; see http://en.wikipedia.org/wiki/Template:PD-self */ ( function ( mw, $ ) {	"use strict";	// Default settings	var settings = {		highlighterFunction: function ( hc ) {			// Default highlighter function			hc.addColorForUsers( '#ff7', [mw.config.get( 'wgUserName' )] );			hc.wrapComments;			hc.addMenuItem;		}	};	/**	 * Messages displayed by this script (in English).	 * Any translations (see below) replace these at runtime.	 */	var msg = {		highlightText: 'Highlight',		highlightTooltip: 'Enable highlighting of your own comments on this page',		unhighlightText: 'Unhighlight',		unhighlightTooltip: 'Disable highlighting of your own comments on this page'	};	/**	 * Translations for messages displayed by this script.	 * To have your translations added, please contact this script's maintainer.	 */	var translations = {	};	// Load translations.	$.extend( msg, translations[document.documentElement.lang] );	// Initialize other enclosed variables. var linkMap = new mw.Map, classNumber = 0, undoLog = null; /**	 * Give comments linking to any given page a specific CSS class. * Essentially, we need to find the comment's container and wrap (except where unnecessary) * everything inside except replies to that comment. We can filter the replies out in that * they are inside other element types that have the effect of indenting the text. * @see unwrapComments */	function wrapComments { // Elements containing comments or indented text (replies to those comments) var commentTags = 'dd, li, p', indentTags = 'dl, ol, ul'; undoLog = []; $( 'a' ).each( function {			// linkMap is a Map from linked page names to CSS class names.			if ( linkMap.exists( this.title ) ) {				var className = linkMap.get( this.title );				$( this ).closest( commentTags ).contents.not( indentTags ).each( function  { var undoEntry = {className: className}; if ( this.nodeType === 1 ) { var $elem = $( this ); if ( !$elem.hasClass( className ) ) { undoEntry.type = 'addClass'; undoEntry.$elem = $elem.addClass( className ); }					} else { undoEntry.type = 'wrap'; undoEntry.$elem = $( this ).wrap( $( ' ', {'class': className} ) ); }					undoLog.push( undoEntry ); } );			}		} );		addMenuItem( true ); }	/**	 * Undo the actions performed by wrapComments using the undo log saved by wrapComments. */	function unwrapComments { for ( var i = 0; i < undoLog.length; ++i ) { var undoEntry = undoLog[i]; if ( undoEntry.type === 'addClass' ) { undoEntry.$elem.removeClass( undoEntry.className ); } else if ( undoEntry.type === 'wrap' ) { undoEntry.$elem.unwrap( undoEntry.$elem ); }		}		undoLog = null; addMenuItem( true ); }	/**	 * Add a group of users whose comments should be given the same CSS class. * @param className The CSS class name to use * @param users An array of usernames */	function addClassForUsers( className, users ) { var ns = mw.config.get( 'wgFormattedNamespaces' ); for ( var i = 0; i < users.length; ++i ) { var userName = users[i]; var userPage = ns[2] + ':' + userName, userTalkPage = ns[3] + ':' + userName; linkMap.set( userPage, className ); linkMap.set( userTalkPage, className ); }	}	/**	 * Add a group of users whose comments should be highlighted in the same color. * @param color The CSS background-color to use * @param users An array of usernames * @return The resulting CSSStyleSheet object */	function addColorForUsers( color, users ) { var className = 'highlighted-comment-' + classNumber++; addClassForUsers( className, users ); return mw.util.addCSS( '.' + className + ' { background-color: ' + color + '; }' ); }	/**	 * Adds or updates a "Highlight" or "Unhighlight" option in the content action menu. * @param updateOnly Do nothing if the menu item does not already exist? */	function addMenuItem( updateOnly ) { var text, tooltip, $oldItem = $( '#ca-highlightcomments' ); if ( updateOnly && !$oldItem.length ) { return; }		if ( undoLog ) { text = msg.unhighlightText; tooltip = msg.unhighlightTooltip; } else { text = msg.highlightText; tooltip = msg.highlightTooltip; }		var link = mw.util.addPortletLink(			'p-cactions', '#', text, 'ca-highlightcomments', tooltip, null, $oldItem[0]		); $oldItem.remove; $( link ).click(function {			if ( undoLog ) {				unwrapComments;			} else {				wrapComments;			}		}); }	// Members exposed to custom highlighter functions var hc = { addClassForUsers: addClassForUsers, addColorForUsers: addColorForUsers, addMenuItem: addMenuItem, wrapComments: wrapComments };	mw.loader.using( 'mediawiki.util', function {		$( function  { $.extend( settings, window.highlightCommentsSettings ); settings.highlighterFunction( hc ); } );	} ); }( mediaWiki, jQuery ));

// https://en.wikipedia.org/wiki/User:NuclearWarfare/Mark-blocked_script.js //If you add this script to your monobook, it will mark all linked blocked users with a strikethrough, and mark all linked indefinitely blocked users with italics and a strikethrough. // // Installation Method 1: // Add the following line to your monobook.js // importScript('User:NuclearWarfare/Mark-blocked script.js'); // // Installation Method 2: // Just copy and paste the uncommented part of this page mw.loader.load('//ru.wikipedia.org/w/index.php?title=MediaWiki:Gadget-markblocked.js&action=raw&ctype=text/javascript');

// Adds a personal edit counter link in toolbar, see https://en.wikipedia.org/wiki/User:Dipankan001/Edit_Count importScript('User:Dipankan001/Edit Count.js')

// https://en.wikipedia.org/wiki/User:Writ_Keeper/Scripts/SearchNamespace.js // Allows the user to select a namespace to search in from the corner search bar prefixString = " Article: \n Article talk: \n Wikipedia: \n Wikipedia talk: \n User: \n User talk: \n WikiProject: \n WikiProject talk: \n Category: \n Category talk: \n Template: \n Template talk: \n Book: \n Book talk: \n Help: \n Special: "; $(document).ready(function {   //retrieve existing elements that we're going to use    searchBar = document.getElementById("searchInput");    searchButton = document.getElementById("searchButton");    searchForm = document.getElementById("searchform");    searchDiv = document.getElementById("simpleSearch");    //create new elements that we're going to insert    prefixList = document.createElement("select");    hiddenInput = document.createElement("input");    //initialize new elements    prefixList.id = "prefixList";    prefixList.innerHTML = prefixString;    hiddenInput.id = "hiddenInput";    hiddenInput.name = "search";    hiddenInput.type = "hidden";    //insert new elements    searchDiv.insertBefore(hiddenInput, searchBar);    searchForm.insertBefore(prefixList, searchDiv);    //modify old ones    searchForm.onsubmit = createSearchTerm;    searchForm.style.marginTop = "0px";    searchBar.removeAttribute("name"); //since we're no longer using the search bar to submit the search terms directly searchDiv.style.display = "inline-block"; prefixList.style.marginTop = ".8em"; prefixList.tabIndex = searchBar.tabIndex; }); //onsubmit handler; concatenates prefixList and searchBar and inserts into hidden input prior to submission function createSearchTerm(e) {   //retrieve used elements    hiddenInput = document.getElementById("hiddenInput");    prefixList = document.getElementById("prefixList");    searchBar = document.getElementById("searchInput");    //do the work (handling special cases)    if(prefixList.value == "Article:")    {        hiddenInput.value = "" + searchBar.value;    }    else if(prefixList.value == "Article talk:")    {        hiddenInput.value = "" + "Talk:" + searchBar.value;    }    else if(prefixList.value == "WikiProject:")    {        hiddenInput.value = "" + "Wikipedia:WikiProject " + searchBar.value;    }    else if(prefixList.value == "WikiProject talk:")    {        hiddenInput.value = "" + "Wikipedia talk:WikiProject " + searchBar.value;    }    else    {             hiddenInput.value = "" + prefixList.value + searchBar.value; } } //