User:Trollocool/global.js

var i18n = { en: { infoboxes:'Infoboxes', sitecss:'Site CSS', personalcss:'My CSS', themescss:'Themes CSS', admins:'Admins' },   de: { infoboxes:'Infoboxen', sitecss:'Wikia CSS', personalcss:'Mein CSS', themescss:'Themes CSS', admins:'Administratoren' },   fr: { infoboxes:'Infoboxes', sitecss:'CSS du Site', personalcss:'Mon CSS', themescss:'CSS du thème', admins:'Administarteurs' } },lang= mw.config.get('wgUserLanguage');

$('.AccountNavigation .subnav li:first') .before(''+i18n[lang].admins+'', ''+i18n[lang].infoboxes+'', ''+i18n[lang].sitecss+'', ''+i18n[lang].themescss+''), '<a href="/wiki/Special:MyPage/wikia.css">'+i18n[lang].personalcss+'</a></li>';

/* chat hacks */ importScriptPage('MediaWiki:TrollocoolChatHacks.js', 'de.trollocool');

importArticles({   type: 'script',    articles: [        'u:dev:PurgeButton/code.js',        'w:dev:MediaWiki:WallGreetingButton/code.js'    ] });

if($.getUrlVar('veaction') == 'edit') location.replace(document.URL.replace('veaction','action'));

/*Verhinderung vom Infobox Builder | Code by Kopcap94*/

(function( $, mw ) {   if ( mw.config.get( 'wgNamespaceNumber' ) !== 10 && !$( '.noarticletext' ).lenght ) return;    var default_infobox =         ' \n' +        '    \n' +        '         \n' +        '    \n' +        '    \n' +        '    \n' +        '         \n' +        '         \n' +        '    \n' +        ' ',        i18n = {            en: 'Create infobox',            ru: 'Создать инфобокс',            de: 'Infobox erstellen'        },        name = ( typeof i18n[ mw.config.get('wgUserLanguage') ] !== 'undefined' ) ?                i18n[ mw.config.get('wgUserLanguage') ] :                i18n.en ;    $( ' ', { id: 'createTemplate', style: 'margin-top: 2px;', text: name }).appendTo( '#WikiaPageHeader' );   $( '#createTemplate' ).on( 'click', function { if ( !confirm( 'Just protecting. Going to create template, right?' ) ) return; $( this ).html('<img src="http://slot1.images.wikia.nocookie.net/__cb1396606660/common/skins/common/images/ajax.gif" />'); $.post('/api.php', {           action: 'edit',            title: mw.config.get( 'wgPageName' ),            summary: 'Creating new PI',            text: default_infobox,            token: mw.user.tokens.get('editToken'),            format: 'json'        }, function( data ) {            var articleID = data.edit.pageid;            $.post( '/wikia.php?controller=TemplateClassificationApi&method=classifyTemplate&format=json', { type: 'infobox', pageId: articleID, editToken: mw.user.tokens.get('editToken') }, function { var link = location.toString, type = ( link.indexOf( '?' ) > -1 ) ? '&' : '?';               location = link + type + 'action=edit&useeditor=source'; });       });    }); })( this.jQuery, this.mediaWiki );

// ==UserScript== // @name        edit links // @namespace   http://tampermonkey.net/ // @version     0.1 // @description open links as edit pages when modifier-clicking // @author      Gaz Lloyd // @match       http://*.wikia.com/* // @exclude     http://*.wikia.com/*action=edit // @grant       none // ==/UserScript== /* jshint -W097 */ 'use strict';
 * (function ($) {

var // customisation variables // modifier key to enable editing // 'control'/'ctrl', 'shift', 'cmd'/'command'/'meta'/'windows' (META key - Windows key on PC, Command key on Mac) or 'middle' (middle mouse button) // shift will always open a new window, control/middle a new tab edit_modifier = 'control',

// links to not modify, as regex link_blacklist = [ /\/Special:/, // special pages /\?action=/, // links with actions already /^#/,        // anchor links within the same page (e.g. toc) ],

//other vars mw = window.mw;

//console.log('setting up click events'); $('#mw-content-text a[href^="/wiki/"]').click(function (event) {       //console.log('clicked!');        var $a = $(event.currentTarget),            href = $a.attr('href'),            i,            pressed = false,            uri;        //console.log($a);        //console.log(event);

for (i = 0; i < link_blacklist.length; i++) { if (href.search(link_blacklist[i]) > -1) { //console.log('link in blacklist'); return; }       }

switch (edit_modifier) { case 'ctrl': case 'control': pressed = event.ctrlKey; break; case 'shift': pressed = event.shiftKey; break; case 'middle': pressed = event.which === 2; break; case 'command': case 'cmd': case 'windows': case 'meta': pressed = event.metaKey; break; }       if (!pressed) { //console.log('modifier not pressed'); return; }

if (!mw.Uri) { //console.log('mw.Uri doesn\'t exist'); return; }       uri = new mw.Uri(href); uri.query.action = 'edit';

event.preventDefault; window.open(uri.toString, '_blank');

}); })(window.jQuery);

importArticles({   type: 'script',    articles: [        'u:dev:CategoryRenameAuto-update/code.js',    ] });