User:JJMC89/common.js

// /*** Import Scripts ***/ importScript('MediaWiki:Gadget-protectionNotices.js'); importScript('MediaWiki:Gadget-SysopTools.js'); importScript('MediaWiki:Gadget-listStyles.js'); importScript('MediaWiki:Gadget-codeBacklinks.js'); /*** /Import Scripts ***/

/*** if (wgPageName == "Special:Watchlist" || wgPageName == "Special:RecentChanges" || wgCanonicalSpecialPageName == "Contributions") { $('span.mw-rollback-link').remove; $('span.mw-usertoollinks').each(function {		$(this).children('a:last').replaceWith("-");		$(this).html($(this).html.replace(" | -", ""));	}); }
 * Make [rollback] and "blocklink" disappear on Watchlist, RecentChanges, and Contributions.
 * From User:Technical 13

/*** // Disabled for testing. /*if (wgPageName == "Special:Watchlist" || wgPageName == "Special:RecentChanges") { setTimeout(function{location = ''},600000); //	importScripts( 'User:Joenuts/Watchlist.js' ); var timeNow = new Date; var minNow = timeNow.getMinutes; var minNow = minNow - 3; var timeCheck = new Date; timeCheck.setMinutes(minNow); var postTime = $('td.mw-enhanced-rc').html; var nbsp = (postTime.match(/ /g)||[]).length; for (i=0;iN ', ''); postTime = postTime.replace('m ', ''); postTime = postTime.replace('b ', ''); postTime = postTime.replace('! ', ''); postTime = postTime.split(':', '2'); var postHour = postTime[0]; var postMin = postTime[1]; var timePost = new Date; timePost.setHours(postHour); timePost.setMinutes(postMin); var timePost = timePost.getTime; timeCheck = timeCheck.getTime; timeNow = timeNow.toLocaleTimeString; var headTitlePrefix = "";// Initialize variable var patrolsRequired = $('abbr.unpatrolled').length - $('table.mw-collapsed').has('abbr.unpatrolled').length; var headTitle = timeNow + " - " + document.title; if (timePost >= timeCheck) { var enhRC = $('td.mw-enhanced-rc').html; $('td[class^="mw-enhanced-rc"]').each(function {this.innerHTML = this.innerHTML.replace(enhRC, ' ' + enhRC + ' ');}); // Using this styles ALL times	  $('td[class^="mw-enhanced-rc"]').css({"font-weight":"bold", "font-size":"12pt"}); headTitlePrefix = "N"; }	if (patrolsRequired !== 0){ if (patrolsRequired > 1) { headTitlePrefix = patrolsRequired + "!" + headTitlePrefix; } else { headTitlePrefix = "!" + headTitlePrefix; }	}	if (headTitlePrefix){ headTitle = headTitlePrefix + " - " + headTitle; } document.title = headTitle; }*/
 * Refresh my WatchList page when viewing every minute
 * From User:Technical 13

/*** * Lets the user to inform an extra summary * Based on meta:User:Krinkle/Scripts/AjaxPatrolLinks.js and w:en:User:Gracenotes/rollback.js * See bugzilla:31270 * FIXME: Use MediaWiki API ***/ function ajaxRollback { var    $rollbackLinks = $('.mw-rollback-link a'), prevUser, rollbackSummaryDefault; function useAJAX(e) { e.preventDefault; var $this = $(this); var href = $this.attr( 'href' ) + '&bot=1'; $this.text('Rolling back...'); $rollbackLinks = $this.parent; $.get(                       href,                        null,                        function( data, status, request ) {                                if ( status == 'success' ) {                                        $this.html(' Rolled back ');                                } else {                                        $this.html(' Rollback failed '); // MediaWiki:Rollbackfailed                                }                        }                ); }       if ( $rollbackLinks.length > 0 ) { rollbackSummaryDefault = 'Reverted edits by $2 (talk) to last revision by $1'/*'Reverted edits by $user (talk) to last revision by '; // MediaWiki:rollback-success prevUser = $('#mw-diff-otitle2').find('a').first.text; if ( prevUser ) { rollbackSummaryDefault += '' + prevUser + '.'; }               else { rollbackSummaryDefault += 'the previous editor.' }*/               $rollbackLinks.each(function{                        var $this = $(this);                        $this.after( $this.clone .text('+sum') .attr( 'class', '') .click(function confirmRollback( e ) {                                       var     url = this.href,                                                user = url.match( /[?&]from=([^&]*)/ );                                        if ( !user ) {                                                return;                                        }                                        user = decodeURIComponent( user[1].replace(/\+/g, ' ') );                                        var extraSum = prompt( 'Enter an extra summary to use for rollback.\n\n' + 'Leave blank to use the default.' + ' $user will be replaced with "' + user + '".' );                                       if (extraSum === null){                                                e.preventDefault;                                        } else if (extraSum === ''){                                                useAJAX.call(this, e);                                        }                                        this.href += "&summary=" + encodeURIComponent( (rollbackSummaryDefault + ' ' + extraSum).replace( /\$user/g, user ) );                                       useAJAX.call(this, e);                                } ) ).after( ' | ' )                       .click( useAJAX );                }); } } $(ajaxRollback);
 * Makes [rollback] links for edits execute without an additional page load. Including self-closing bookmarklet option.

/*** * This script lets you use a custom summary with the rollback feature * by adding a "sum" link wherever a rollback link appears. When you * click "sum" you are prompted for a custom summary, and the script * adds an additional summary parameter to the rollback URL submitting it. * * For usage and extra options, see the talk page. * Author Gracenotes (http://en.wikipedia.org/wiki/User:Gracenotes/rollback.js) ***/ // Disabled: Included in ajaxRollback above. /*function addSumLink { var rbnode = [], diffnode, index = {}, gebcn = document.getElementsByClassName ? function(a, b, c) { return a.getElementsByClassName(c) } : getElementsByClassName; if (typeof rollbackLinksDisable == 'object' && rollbackLinksDisable instanceof Array) for (var i = 0; i < rollbackLinksDisable.length; i++) index[rollbackLinksDisable[i]] = true; if (!('user' in index) && wgCanonicalSpecialPageName == "Contributions" ||       !('recent' in index) && wgCanonicalSpecialPageName == "Recentchanges" ||        !('watchlist' in index) && wgCanonicalSpecialPageName == "Watchlist") rbnode = gebcn(document.getElementById("bodyContent"), "span", "mw-rollback-link"); else if (!('history' in index) && wgAction == "history") rbnode = gebcn(document.getElementById("pagehistory"), "span", "mw-rollback-link"); else if (!('diff' in index) && (diffnode = document.getElementById("mw-diff-ntitle2"))) rbnode = gebcn(diffnode, "span", "mw-rollback-link"); for (var i = 0, len = rbnode.length; i < len; i++) addRollbackSummaryLink(rbnode[i]); }; function confirmRollback { var url = this.href; var user = url.match(/[?&]from=([^&]*)/); if (!user) return; user = decodeURIComponent(user[1].replace(/\+/g, " ")); var summary = prompt("Enter a summary to use for rollback.\n\nLeave blank to use the default. $user will be replaced with \"" + user + "\".",                        rollbackSummaryDefault); if (summary == undefined) return false; else if (summary == "") return true; this.href += "&summary=" + encodeURIComponent(summary.replace(/\$user/g, user)); return true; }; function addRollbackSummaryLink(rbnode) { var rblink = rbnode.getElementsByTagName("a")[0]; var alink = rblink.cloneNode(true); alink.className = ""; //don't confuse other scripts alink.firstChild.nodeValue = "sum"; alink.onclick = confirmRollback; rbnode.insertBefore(alink, rblink.nextSibling); rbnode.insertBefore(document.createTextNode(" | "), alink); }; if (typeof rollbackLinksDisable == 'undefined') rollbackLinksDisable = []; if (typeof rollbackSummaryDefault == 'undefined') rollbackSummaryDefault = ""; addOnloadHook(addSumLink);*/

/*** // Disabled: Included in ajaxRollback above. // mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Krinkle/Scripts/AjaxPatrolLinks.js&action=raw&ctype=text/javascript');
 * AjaxPatrolLinks
 * Author: Krinkle
 * File:Krinkle_AjaxPatrolLinks.js
 * http://meta.wikimedia.org/wiki/User:Krinkle/Scripts/AjaxPatrolLinks
 * http://meta.wikimedia.org/wiki/User:Krinkle/Scripts/AjaxPatrolLinks.js

/*** // Disabled until needed. /*$.getScript( 'http://meta.wikimedia.org/w/index.php?title=User:Krinkle/Scripts/addDeleteReasons.js&action=raw&ctype=text/javascript', function{ krAddDeleteReasons.File( 'Reason here to delete a file' );  krAddDeleteReasons.File( 'Some other reason to delete a file' );
 * Add custom delete reasons
 * Author: Krinkle
 * File:Krinkle_addDeleteReasons.js
 * http://meta.wikimedia.org/wiki/User:Krinkle/Scripts/addDeleteReasons
 * http://meta.wikimedia.org/wiki/User:Krinkle/Scripts/addDeleteReasons.js

});*/

/*** // Disabled for testing. // mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Krinkle/RTRC.js&action=raw&ctype=text/javascript');
 * Real-Time Recent Changes (RTRC)
 * Author: Krinkle
 * File:Krinkle_RTRC.js
 * http://meta.wikimedia.org/wiki/User:Krinkle/Tools/Real-Time_Recent_Changes
 * http://meta.wikimedia.org/wiki/User:Krinkle/RTRC.js

/*** // Disabled for testing. // mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Krinkle/Tools/WhatLeavesHere.js&action=raw&ctype=text/javascript');
 * What Leaves Here
 * Author: Krinkle
 * File:Krinkle_WhatLeavesHere.js
 * http://meta.wikimedia.org/wiki/User:Krinkle/Tools/WhatLeavesHere
 * http://meta.wikimedia.org/wiki/User:Krinkle/Tools/WhatLeavesHere.js

/** * Extra buttons in toolbar * Author: Krinkle * File:Krinkle_InsertWikiEditorButton.js * http://meta.wikimedia.org/wiki/User:Krinkle/Scripts/insertVectorButtons * http://meta.wikimedia.org/wiki/User:Krinkle/insertVectorButtons.js */ // Disabled until needed. /*jQuery.getScript('//meta.wikimedia.org/w/index.php?title=User:Krinkle/Scripts/InsertWikiEditorButton.js&action=raw&ctype=text/javascript', function {	// Happy face	krInsertWikiEditorButton({ id: "mw-customeditbutton-myspecialbutton", icon: "//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png", label: 'Insert happy face', insertBefore: '', sampleText: 'Happy face' });	// Monkey	krInsertWikiEditorButton({ id: 'mw-customeditbutton-anotherspecialbutton', icon: '//upload.wikimedia.org/wikipedia/commons/thumb/1/1b/Gnome-face-monkey.svg/22px-Gnome-face-monkey.svg.png', label: 'Insert monkey', insertBefore: '', sampleText: 'Happy face' }); });*/

/**************************************************** //
 * Krinkle Scripts                                  *
 * http://meta.wikimedia.org/wiki/User:Krinkle/Tools *