User:Psl631/global.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
mw.loader.localLoad = function( url ) { return mw.loader.load( '//minecraft.gamepedia.com/index.php?title=' + url + '&action=raw&ctype=text/javascript' ); };
/** Scripts **/
// [[User:Majr/docTabs.js]]
// Adds Doc + Doc discussion tabs to template and module pages and
// changes Template/Module + Discussion tabs to always link to the original template/module + discussion page
if (
$.inArray( mw.config.get( 'wgNamespaceNumber' ), [ 10, 11, 828, 829 ] ) > -1 ||
$.inArray( mw.config.get( 'wgNamespaceNumber' ), [ 2, 3 ] ) > -1 &&
mw.config.get( 'wgTitle' ).replace( /\/doc$/, '' ).search( /\.(js|css)$/ ) > -1
) {
mw.loader.localLoad( 'User:Majr/docTabs.js' );
}
// [[User:Majr/Prism.js]]
// Adds JavaScript, CSS and Lua syntax highlighting, see file for license
// Requires a theme from http://prismjs.com to be added to usercss
mw.loader.localLoad( 'User:Majr/Prism.js' );
// [[User:Majr/inputCounter.js]]
// Adds a character counter to input fields
mw.loader.localLoad( 'User:Majr/inputCounter.js' );
// [[User:Majr/codeLinks.js]]
mw.loader.localLoad( 'User:Majr/codeLinks.js' );
// [[User:Majr/renderConsoleOutput.js]]
// Allows the output wikitext of the lua console to be rendered
if ( $( '#mw-scribunto-console' ).length ) {
mw.loader.localLoad( 'User:Majr/renderConsoleOutput.js' );
}
/** General fixes **/
$( function() {
'use strict';
// Add a subpages link to pages
if ( mw.config.get( 'wgArticleId' ) != 0 ) {
mw.util.addPortletLink (
'p-tb',
'/Special:PrefixIndex/' + mw.config.get( 'wgRelevantPageName' ) + '/',
'Subpages',
't-subpages',
'Subpages of the article'
);
}
/** Mostly direct code from [[User:Majr/hydra.js]] **/
// Modify the editing toolbar
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) > -1 ) {
mw.loader.using( 'ext.wikiEditor.toolbar', function() {
// Modify the text added by the signature button.
var $button = $( '#wikiEditor-section-main > .group-insert > a[rel="signature"]' );
if ( $button.length ) {
var action = $button.data( 'action' );
action.options.pre = '<span class=nowrap>~~' + '~~</span>';
$button.data( 'action', action );
}
// Add an option to insert <code> tags
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
code: {
label: 'Code formatting',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/6/62/Toolbar_code.png',
action: {
type: 'encapsulate',
options: { pre: '<code>', post: '</code>' }
}
}
}
// Add an option to insert template braces
} ).wikiEditor( 'addToToolbar', {
section: 'advanced',
group: 'insert',
tools: {
sign: {
label: 'Template',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/4/43/Button-template.png',
action: {
type: 'replace',
options: { pre: '{{', post: '}}' }
}
}
}
// Add characters to the symbols insert page
} ).on( 'wikiEditor-toolbar-buildSection-characters', function (event, section) {
section.pages.symbols.characters.push( '¦', '²{', '}²' );
} );
} );
}
// Add 0th section edit button to first infobox which is in the 0th section
var $firstInfobox = $( '.notaninfobox' ).first();
if ( !$firstInfobox.prevAll( 'h1, h2, h3, h4, h5, h6' ).length ) {
$firstInfobox.children( '.infobox-title' ).css( 'padding-left', 50 ).prepend(
$( '<span>' ).addClass( 'mw-editsection' ).css( {
float: 'right',
lineHeight: 'inherit'
} ).append(
'[',
$( '<a>' ).prop( 'href', '/' + mw.config.get( 'wgPageName' ) + '?action=edit§ion=0' ).text( 'edit' ),
']'
)
);
}
} );
/** Testing stuff **/
mw.loader.load( '//minecraft.gamepedia.com/index.php?title=User:Majr/goToTop.js&action=raw&ctype=text/javascript' );
/* Welcome script from [[User:ITechieGamer]] */
/* Add image at the top right corner to blocked users' userpages */
if ( mw.config.get( 'wgRelevantUserName' ) ) {
$( function() {
'use strict';
var title = 'This user is blocked from editing';
( new mw.Api() ).get( {
action: 'query',
format: 'json',
list: 'blocks',
formatversion: 2,
bkusers: mw.config.get( 'wgRelevantUserName' )
} ).done( function( data ) {
if ( data.query.blocks.length ) {
$( '.mw-indicators' ).prepend(
'<a href="//en.wikipedia.org/wiki/WP:Blocking policy" class="mw-indicator" id="gadget-blockindicator" title="' + title + '">' +
'<img src="//upload.wikimedia.org/wikipedia/commons/4/4f/Blocked_user.svg" height="20">' +
'</a>'
);
}
} );
} );
}
/* and also a padlock to locked user accounts userpages */
if ( mw.config.get( 'wgRelevantUserName' ) ) {
$( function() {
'use strict';
var title = 'This user account has been locked';
( new mw.Api() ).get( {
action: 'query',
format: 'json',
list: 'locks',
formatversion: 2,
lkusers: mw.config.get( 'wgRelevantUserName' )
} ).done( function( data ) {
if ( data.query.locks.length ) {
$( '.mw-indicators' ).prepend(
'<a href="//meta.miraheze.org/wiki/Locked_account" class="mw-indicator" id="gadget-lockindicator" title="' + title + '">' +
'<img src="//upload.wikimedia.org/wikipedia/commons/4/4f/Padlock-purple.svg" height="20">' +
'</a>'
);
}
} );
} );
}
// Scripts, some imported from Wiki Pedia, and modified to use on this wiki //
/* Auto-sign posts */
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=user:perhelion/signing.js&action=raw&ctype=text/javascript' );
mw.loader.load('//en.wikipedia.org/w/index.php?title=Mediawiki:Gadget-popups.js&action=raw&ctype=text/javascript');
mw.loader.load('//terraria.gamepedia.com/index.php?title=MediaWiki:Gadget-PastBlocks.js&action=raw&ctype=text/javascript');
/* IP info */
mw.loader.load('//terraria.gamepedia.com/index.php?title=MediaWiki:Gadget-ipInfo.js&action=raw&ctype=text/javascript');
/* [edit] link for the top section */
mw.loader.load('//en.wikipedia.org/w/index.php?title=Mediawiki:Gadget-edittop.js&action=raw&ctype=text/javascript');
/* More Watchlist tools */
mw.loader.load( '//minecraft.gamepedia.com/index.php?title=User:Psl85/smartwatchlist.js&action=raw&ctype=text/javascript' );
/* RC options */
mw.loader.load( '//minecraft.gamepedia.com/index.php?title=User:Psl85/rc.js&action=raw&ctype=text/javascript' );
/* Dropdown menus for page tools and options */
mw.loader.load( '//minecraft.gamepedia.com/index.php?title=User:Psl85/dropdownmenu.js&action=raw&ctype=text/javascript' );
/* Drop down menus to choose edit summary */
mw.loader.load( '//minecraft.gamepedia.com/index.php?title=User:Psl85/editsummaries.js&action=raw&ctype=text/javascript' );
// [[User:Ais523/votesymbols.js]]
// Code for adding icons to !votes in AfDs, RfAs, etc.. Doesn't affect the page, just
// shows the icons when this code is installed.
// Please see [[:Image:Votesymbols.js-enhanced_SfD.png]] for copyright info on the images that are added.
function lowerNoPunct(s)
{
return s.toLowerCase().split('.').join('').split(',').join('').split(':').join('').split(';').join('').split('+').join('');
}
/* ======================================================== *\
** igloo frontend manager - main
**
** The igloo frontend manager handles the client system,
** displaying information to the user, as well as allowing
** the user to interact with the program.
**
** ====================================================== **
** igloo anti-vandalism tool for Wikipedia
** based off of the script igloo by Alex Barley
** By: User:Kangaroopower
**
** For instructions, see [[Wikipedia:Igloo]]
** ====================================================== **
**
** You may copy, modify and distribute this software as
** desired, providing that all previous contributors retain
** correct attribution.
**
** ====================================================== **
** tracker: [[Wikipedia:Igloo]]
\* ======================================================== */
window.iglooBranch = 'master';
mw.loader.load("//tools.wmflabs.org/igloo/code/Igloo/gloo.js");
//
$(function() {
if(mw.config.get('wgNamespaceNumber')===0) return; //avoid article space, generally speaking
var vs=
"//upload.wikimedia.org/wikipedia/commons/thumb/9/94/Symbol_support_vote.svg/15px-Symbol_support_vote.svg.png#"+
"//upload.wikimedia.org/wikipedia/commons/thumb/d/d0/Symbol_keep_vote.svg/15px-Symbol_keep_vote.svg.png#"+
"//upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Symbol_oppose_vote.svg/15px-Symbol_oppose_vote.svg.png#"+
"//upload.wikimedia.org/wikipedia/commons/thumb/8/89/Symbol_delete_vote.svg/15px-Symbol_delete_vote.svg.png#"+
"//upload.wikimedia.org/wikipedia/commons/thumb/8/89/Symbol_neutral_vote.svg/15px-Symbol_neutral_vote.svg.png#"+
"//upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Symbol_merge_vote.svg/15px-Symbol_merge_vote.svg.png#"+
"//upload.wikimedia.org/wikipedia/commons/thumb/5/50/Symbol_move_vote.svg/15px-Symbol_move_vote.svg.png#"+
"//upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Symbol_redirect_vote.svg/15px-Symbol_redirect_vote.svg.png#"+
"//upload.wikimedia.org/wikipedia/commons/thumb/b/ba/Symbol_opinion_vote.svg/15px-Symbol_opinion_vote.svg.png#"+
"//upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Symbol_comment_vote.svg/15px-Symbol_comment_vote.svg.png#"+
"//upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Symbol_unsupport_vote.svg/15px-Symbol_unsupport_vote.svg.png#"+
"//upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Symbol_question.svg/15px-Symbol_question.svg.png#"+
"//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Symbol_divide_vote.svg/15px-Symbol_divide_vote.svg.png#"+
"//upload.wikimedia.org/wikipedia/commons/thumb/5/54/Symbol_wait.svg/15px-Symbol_wait.svg.png#"+
"//upload.wikimedia.org/wikipedia/commons/thumb/b/bc/Face-grin.svg/15px-Face-grin.svg.png#"+
"//upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Symbol_support2_vote.svg/15px-Symbol_support2_vote.svg.png#"+
"//upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Symbol_no_support_vote.svg/15px-Symbol_no_support_vote.svg.png";
var vt=vs.split("#");
var la=[];
la['support']=0; la['endorse']=0;
la['keep']=1; la['allow']=1; la['permit']=1
la['oppose']=2; la['overturn']=2; la['object']=2; la['disallow']=2
la['delete']=3;
la['neutral']=4;
la['merge']=5; la['upmerge']=5;
la['move']=6; la['rename']=6; la['userfy']=6; la['transwiki']=6; la['listify']=6; la['convert']=15
la['redirect']=7; la['retarget']=7;
la['opinion']=8; la['relist']=8; la['subst']=8; la['salt']=8; la['change']=8; la['list']=8;
// Note that icon 8 on the list is often used for debate-specific !votes
la['comment']=9; la['update']=9; la['note']=9;
la['delist']=10;
la['question']=11;
la['split']=12; la['disambiguate']=12; la['set index']=12; la['SIA']=12; la['dab']=12; la['dabify']=12;
la['wait']=13;
la['bjaodn']=14;
la['undelete']=15; la['restore']=15
la['close']=16;
var btc=document.body.getElementsByTagName("B");
i=btc.length;
while(i--)
{
var j,k;
j=btc[i].innerHTML.split("<").join(" ").split(">").join(" ").split("/").join(" ").split(" ");
k=0;
var x="";
while(k<j.length)
{
if(lowerNoPunct(j[k])=="don't"||lowerNoPunct(j[k])=='not'
||lowerNoPunct(j[k])=='no'||lowerNoPunct(j[k])=='without') break;
var l=la[lowerNoPunct(j[k])];
if(l!==undefined)
{
x+='<img src="'+vt[l]+'" alt="" /> '
}
k++;
}
if(x!=="") btc[i].innerHTML=x+btc[i].innerHTML;
}
});
//[[Category:Wikipedia scripts]]
/*
Put some functions in the toolbox for the anti-vandal whack-a-mole game.
Documented at http://en.wikipedia.org/wiki/User:Kbh3rd/Vandal_warning_toolbox
*/
// <pre><nowiki>
/**
* charinsert loader
*/
$( function () {
var tab, tablink;
tab = document.getElementById('ca-addsection');
if ( !tab ) {
return;
}
tablink = tab.getElementsByTagName('a')[0];
if ( !tablink ) {
return;
}
tablink.firstChild.nodeValue = '+';
if ( mw.config.get( 'skin' ) === 'monobook' ) {
tablink.style.paddingLeft = ".4em";
tablink.style.paddingRight = ".4em";
}
});
// This only shows alerts for things after this handler is installed of course.
// Because this is a gadget, error reporting can thus be inconsistent.
var originalErrorHandler = window.onerror || null;
// Column and error args are optional
window.onerror = function ( message, url, line, colomn, error ) {
var $msg = $( '<p>' );
if ( url ) {
$( '<span>' )
.text( url + ' at line ' + line + ': ' )
.appendTo( $msg );
}
$( '<span>' )
.text( message )
.appendTo( $msg );
mw.notify( $msg, {
autoHide: true,
autoHideSeconds: 10,
tag: null,
title: 'An error occured:',
type: 'error'
} );
if (originalErrorHandler) {
return originalErrorHandler.apply(this, arguments);
}
};
// unbind on leaving the page
$( window )
.on( 'unload', function () {
window.onerror = originalErrorHandler;
} );
$( function() {
'use strict';
var restrictions = mw.config.get( 'wgRestrictionEdit' );
if ( restrictions ) {
if ( restrictions.indexOf( 'sysop' ) !== -1 ) {
$( '.mw-indicators' ).prepend( '<img title="This page is protected from editing" id="gadget-protectionindicators-' + restrictions[ 0 ] + '" src="//upload.wikimedia.org/wikipedia/commons/5/59/Padlock.svg" height="20" />' );
} else if ( restrictions.indexOf( 'autoconfirmed' ) !== -1 ) {
$( '.mw-indicators' ).prepend( '<img title="This page is semi-protected from editing" id="gadget-protectionindicators-' + restrictions[ 0 ] + '" src="//upload.wikimedia.org/wikipedia/commons/f/fc/Padlock-silver.svg" height="20" />' );
}
}
}
);
$( '#ca-nstab-user a' ).text( 'Userpage' );
$( '#ca-talk a' ).text( 'Talk' );
$( '#ca-history a' ).text( 'Page history' );
/* Open external links in new tab */
* @source mediawiki.org/wiki/Snippets/Open_external_links_in_new_window
* @version 5
*/
mw.hook('wikipage.content').add(function($content) {
// Second selector is for external links in Parsoid HTML+RDFa output (bug 65243).
$content.find('a.external, a[rel="mw:ExtLink"]').each(function () {
// Can't use wgServer because it can be protocol relative
// Use this.href property instead of this.getAttribute('href') because the property
// is converted to a full URL (including protocol)
if (this.href.indexOf(location.protocol + '//' + location.hostname) !== 0) {
this.target = '_blank';
if ( this.rel.indexOf( 'noopener' ) < 0 ) {
this.rel += ' noopener'; // the leading space matters, rel attributes have space-separated tokens
}
if ( this.rel.indexOf( 'noreferrer' ) < 0 ) {
this.rel += ' noreferrer'; // the leading space matters, rel attributes have space-separated tokens
}
}
});
});
mw.loader.load('//meta.miraheze.org/w/index.php?title=User:Void/createWikiNotify.js&action=raw&ctype=text/javascript');
mw.loader.load('//meta.miraheze.org/w/index.php?title=User:Void/links.js&action=raw&ctype=text/javascript');
mw.loader.load( '//meta.miraheze.org/w/index.php?action=raw&ctype=text/javascript&title=User:Void/centralAuthLink.js' );
mw.loader.load( '//meta.miraheze.org/w/index.php?action=raw&ctype=text/javascript&title=User:Zppix/cvtToolbox.js');
mw.loader.load('//en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:Writ_Keeper/Scripts/massRollback.js');
mw.loader.load( '//meta.miraheze.org/w/index.php?action=raw&ctype=text/javascript&title=User:MacFan4000/globalBlockLink.js' );
/* Counts all your edits and saves them to a page ( http://en.wikipedia.org/wiki/User:Kanegasi/editcounter ) */
if (mw.config.get('wgTitle') === mw.config.get('wgUserName') && mw.config.get('wgNamespaceNumber') === 2) {
/* begin options */
/* end options */
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Kanegasi/editcounter.js&action=raw&ctype=text/javascript');
}