User:Superwatery/global.js

window.AutoCreateUserPagesConfig = { content: '', summary: 'Automated userpage and message greeting created by myself 😜. ' };

window.AjaxThreadDeleteConfig = { fastDelete: true, reason: 'Deleting superfluous comment' };

window.WHAMBotMe = true; window.WHAMBotReason = "Cleanup"; window.WHAMDelay = 100; window.WHAMDeleteReason = "Deleting Spam or Vandalism"; window.WHAMBlockReason = "Abusing multiple accounts/trolling/vandalism/spam";

window.AjaxBlock = { expiryTimes: { '2 hours': '2 hours', '1 day': 'one day', '1 week': 'a week', '2 months': '2m', 'never': 'Never' },   blockReasons: { 'Vandalism': 'Vandalism', 'Spam': 'Spam', 'Under the legal age': 'COPPA', 'Removing information/blanking articles': 'Blanking', 'Failing to comply with the File Policy': 'File policy', 'Inserting false information': 'Inserting false information', 'Removing content from pages': 'Removing content from pages', 'Inserting nonsense/gibberish into page(s)': 'Inserting nonsense/gibberish into page(s)', 'Intimidating behavior/harassment': 'Intimidating behavior/harassment', 'Uploading inappropriate images/videos': 'Uploading inappropriate images/videos', 'Spamming comments/forum threads': 'Spamming comments/forum threads', 'ToU violation':"Violation of Fandom's Terms of Use", 'Abusing multiple accounts': 'Multiaccounts' },   check: { talk: true, autoBlock: true, override: true } };

window.category = ['Candidates for deletion', 'Unused images']; window.reason = 'Housekeeping'; window.quickDeleteDelay = '800';

window.nukeDeleteReason = "Deleting Spam or Vandalism"; window.nukeDelay = 1000;

window.massEditConfig = { editInterval: 300 };

(function ($) {   //add quick links to user    if ([2, 3, 500, 1200].indexOf(wgNamespaceNumber) === -1) return;    var $container = $(' links '),        $links = $(' '),        username = wgPageName.replace(/.*?\:/, ).replace(/\/.*/, ),        links = [            '//community.wikia.com/wiki/user:' + username + '/global.js',            wgArticlePath.replace('$1', 'user:' + username + '/common.js'),            wgArticlePath.replace('$1', 'user:' + username + '/wikia.js'),            '//community.wikia.com/wiki/user:' + username + '/global.css',            wgArticlePath.replace('$1', 'user:' + username + '/common.css'),            wgArticlePath.replace('$1', 'user:' + username + '/wikia.css'),        ];    links.forEach(function (link) { $links.append(           $('', { href: link, text: link.replace(/.*\//, '') })       );    });    $links.find('a').wrap('');    $container.append($links);    $('.page-header__title, .masthead-info [itemprop="name"]').after($container);    mw.util.addCSS('.userlinks-container{display:inline-block;vertical-align:top;background:inherit}\ .userlinks-links{display:none;position:absolute;z-index:1000;background:inherit}\ .userlinks-container:hover .userlinks-links{display:block}\ .userlinks-links li{list-style:none}'); })

/* Any JavaScript here will be loaded for all users on every page load. See w:c:dev:AjaxRC for info & attribution */ AjaxRCRefreshText = 'Auto-Refresh'; AjaxRCRefreshHoverText = 'Automatically refresh the page'; ajaxPages = ["Special:RecentChanges","Special:WikiActivity","Special:UncategorizedPages","Special:AllPages"]; importScriptPage('AjaxRC/code.js', 'dev');

window.pageNames = [ 'PAGENAMEWITHOUTPREFIX', 'ANOTHERPAGENAMEWITHOUTPREFIX' ]; window.pageData = [ 'DATAFORFIRSTPAGEINABOVELIST', 'DATAFORSECONDPAGEINABOVELIST' ]; window.pagePurpose = [ 'PURPOSEOFFIRSTPAGE', 'PURPOSEOFSECONDPAGE' ]; // Display 12 hour time followed by day, month (English, full name) // and year with "(UTC)" at the end window.DisplayClockJS = { format: '%2I:%2M:%2S %p %2d %{January;Febuary;March;April;May;June;July;August;September;October;November;December}m %Y (UTC)', location: 'header', hoverText: 'This is what the user sees when they hover their mouse over the link', interval: 500, /* How often the timer updates in milliseconds (1000=1 second) */ monofonts: 'Rubik', /* The font the clock uses by default */ offset: 480 /* Time offset from UTC in minutes - 480 changes the clock from UTC to CST (China Standard Time) */ }; importArticle({type:'script', article:'w:c:dev:DisplayClock/code.js'});

window.fdButtons = [ {       summary: 'Housekeeping', label: 'Housekeeping' },   {        summary: 'Vandalism', label: 'Vandalism' },   {        summary: 'Spam', label: 'Spam' },       {        summary: 'Cleanup', label: 'Cleanup' },   {        summary: 'Garbage', label: 'Garbage' },   {        summary: 'Low quality article; not really needed like this. ',       label: 'LQANRNLT (Arya Snow)' },           {        summary: 'Author request', label: 'Author request' },           {        summary: 'Superfluous', label: 'Superfluous' },           {        summary: 'Absolutely zero information', label: 'Absolutely zero information' },           {        summary: 'Copyright Violation', label: 'Copyright Violation' },           {        summary: 'Marked for Deletion', label: 'Marked for Deletion' },           {        summary: 'Broken redirect', label: 'Broken redirect' },   {        summary: 'Unused redirect', label: 'Unused redirect' },           {        summary: 'Redirect left from pagemove', label: 'Redirect left from pagemove' },           {        summary: 'Inappropriate page', label: 'Inappropriate page' },   {        summary: 'Pointless', label: 'Pointless' },   {        summary: 'No longer needed', label: 'No longer needed' },   {        summary: 'Violation of the ToU', label: 'Violation of the Term of Use' },   {        summary: 'Shhh', label: 'Shhh' },   {        summary: 'Abusing HTML', label: 'Abusing HTML' } ];

/* Installed scripts */ importArticles({	type: 'script',	articles: [		// ...		'u:dev:DisplayClock/code.js',		'u:dev:MediaWiki:SearchEnhancements.js',		'u:dev:MediaWiki:ShowUserGroups.js',		'u:dev:MediaWiki:AjaxThreadDelete/code.js',		'u:dev:MediaWiki:PurgeButton/code.js',		'u:dev:MediaWiki:Status/code.js',	   'u:dev:MediaWiki:TemplateTypeButtons/code.js',		'u:dev:MediaWiki:AutoPurge/code.js',		'u:dev:MediaWiki:MinimalJSPages.js',		'u:dev:MediaWiki:WHAM/code.2.js',		'u:dev:MediaWiki:MassNullEdit/code.js',		'u:dev:MediaWiki:AjaxThreadDelete/code.js',		'u:dev:MediaWiki:AjaxEdit.js',		'u:dev:MediaWiki:FastDelete/code.js',        'u:dev:MediaWiki:AdminDashboard block/code.js',		'u:dev:MediaWiki:MobileEditor.js',		'u:dev:MediaWiki:QuickDelete/code.js',		'u:dev:MediaWiki:Quick Management/code.js',		'u:dev:MediaWiki:AjaxUndo/code.js',        'u:dev:MediaWiki:AjaxEditSection.js',		'u:dev:MediaWiki:DateInserter/code.js', 'u:dev:MediaWiki:QuickThreads/code.js', 'u:dev:MediaWiki:CategoryQuickRemove.js', 'u:dev:MediaWiki:ReplyBottom/code.js', 'u:dev:MediaWiki:UTCClock/code.js', 'u:dev:MediaWiki:SelectiveDelete/code.js', 'u:dev:MediaWiki:WebArchive.js', 'u:dev:MediaWiki:FastFileDelete.js', 'u:dev:MediaWiki:RailWAM/code.js', 'u:dev:MediaWiki:AjaxRedirect/code.js', 'u:dev:MediaWiki:AddNukeLink.js', 'u:dev:MediaWiki:MisspelledPage/code.js', 'u:dev:MediaWiki:EditorFilter/code.js', 'u:dev:MediaWiki:Thread Inspection/code.js', 'u:dev:MediaWiki:FastFileDelete.js', 'u:dev:MediaWiki:UserActivityTab/code.js', 'u:dev:MediaWiki:AvatarLink.js', 'u:dev:MediaWiki:AjaxDelete/code.js', 'u:dev:MediaWiki:FixEditorTooltips.js', 'u:dev:MediaWiki:ProtectionIcons.js', 'u:dev:MediaWiki:NewImages.js', 'u:dev:MediaWiki:AjaxThreadUnfollow/code.js', 'u:dev:MediaWiki:AjaxThreadDelete/code.js', 'u:dev:MediaWiki:QuickComments/advanced.js', 'u:dev:MediaWiki:MercuryPreview.js', 'u:dev:MediaWiki:Quotes.js', 'u:dev:MediaWiki:DiscussionsRailModule/code.js', 'u:dev:MediaWiki:AjaxBlock/code.js', 'u:dev:MediaWiki:Sine/code.js', 'u:dev:MediaWiki:UserActivityLink.js', 'u:dev:MediaWiki:WikiPlus/code.js', 'u:dev:MediaWiki:SelectiveDelete/code.js', 'u:dev:MediaWiki:FasterBanModule/code.js', 'u:dev:MediaWiki:CreateSpecialPage/code.js', 'u:dev:MediaWiki:Quotes.js', 'u:dev:MediaWiki:UsefulDropdown/code.js', 'u:cjrichards-and-applemasterexpert:MediaWiki:Rollback/code.js', 'u:dev:MediaWiki:HoverEditCount/code.js', 'u:dev:MediaWiki:MassRenameRevert/code.js', 'u:dev:MediaWiki:MastheadGender/code.js', 'u:dev:MediaWiki:FloatingTableHeader/Code.js', 'u:dev:MediaWiki:QuickAccessToCSSAndJS/code.js', 'u:dev:MediaWiki:CopyCodeButton.js', 'u:dev:MediaWiki:AddNukeLink.js', 'u:dev:MediaWiki:SelectContent.js', 'u:dev:MediaWiki:PageCreator/code2.js', 'u:dev:MediaWiki:MobileEditor.js', 'u:dev:MediaWiki:StickySummary.js', 'u:dev:MediaWiki:FollowDropdown/code.js', 'u:dev:MediaWiki:AjaxBatchDelete.js', 'u:dev:MediaWiki:WikiStatistics/code.js', 'u:dev:MediaWiki:EditBio/code.js', 'u:dev:MediaWiki:PortableListUsers.js', 'u:dev:MediaWiki:QuickDelete/code.js', 'u:dev:MediaWiki:ImprovedFooter/code.js', 'u:dev:MediaWiki:SearchEnhancements.js', 'u:dev:DisplayTimer/code.js', 'u:dev:MediaWiki:RevealAnonIP/usercode.js', 'u:dev:MediaWiki:ListAdmins/code.js', 'u:dev:MediaWiki:FastDelete/code.js', 'u:dev:MediaWiki:CacheCheck/code.js', 'u:dev:MediaWiki:MassEdit/code.js', 'u:dev:MediaWiki:HighlightUsers/code.js', 'u:dev:MediaWiki:AbuseLogRC.js', 'u:dev:MediaWiki:UserAccountAge/code2.js', 'u:dev:MediaWiki:ClearSandbox/code.js', 'u:dev:MediaWiki:View Source/code.js', 'u:dev:MediaWiki:SearchSuggest/code.js', 'u:dev:MediaWiki:CollapseMessage.js', 'u:dev:MediaWiki:AvatarLink.js', 'u:dev:MediaWiki:MobileEditor.js', 'u:dev:MediaWiki:PageMakerPro/code.js', 'u:dev:MediaWiki:Nuke/code.js', 'u:dev:MediaWiki:AnchoredRollback/code.js', 'u:dev:MediaWiki:Discussions Delete All/code.js', 'u:dev:MediaWiki:AtUsername/code.js', 'u:dev:MediaWiki:AddSectionButton/code.js', 'u:dev:MediaWiki:RollbackSpamUserContribs/code.js', 'u:dev:MediaWiki:PiniginsUserInfo/code.js', 'u:dev:MediaWiki:MassBlock/code.js', 'u:dev:MediaWiki:SeeMoreActivityButton/code.js', 'u:dev:MediaWiki:GlobalEditcount/code.js', 'u:dev:MediaWiki:WallGreetingButton/code.js', 'u:dev:MediaWiki:RandomPageShortcut/code.js', 'u:dev:MediaWiki:VSTFReport.js', 'u:dev:MediaWiki:VSTF Report Menu/code.js', 'u:dev:MediaWiki:MarkForDeletion/code.js', 'u:dev:MessageWallUserTags/code.js', 'u:dev:MediaWiki:ColorPreview/code.js', 'u:dev:MediaWiki:Standard Edit Summary/code.js', 'u:dev:MediaWiki:SandboxTab/code.js', 'u:dev:MediaWiki:AdminDashboard JS-Button/code.js', 'u:dev:BackToTopButton/code.js', 'u:dev:LastEdited/code.js', 'u:dev:MediaWiki:RevertOldGlobalNav/code.js', 'u:dev:MediaWiki:BlogLink/code.js', 'u:dev:MediaWiki:SourceEditButton.js', 'u:dev:MediaWiki:NullEditButton/code.js', 'u:dev:MediaWiki:EditIntroButton/code.js', 'u:kocka:User:KockaAdmiralac/AutoCreateUserPages.javascript', 'u:kocka:MediaWiki:AjaxThreadDelete/code.js', 'u:dev:MediaWiki:ModernButtons/code.js', 'u:dev:MediaWiki:SimilarArticles/code.js', 'u:dev:MediaWiki:PurgeButton/code.js', 'u:dev:MediaWiki:ChatOptions/code.js', 'u:dev:MediaWiki:EditIntroButton/code.js', 'u:dev:MediaWiki:SourceEditButton.js', 'u:dev:MediaWiki:BlockedByChatUsers/code.js', 'u:dev:MediaWiki:RecentChangesMultiple/code.2.js', 'u:dev:MediaWiki:LinkPreview/code.js', 'u:dev:MediaWiki:AdminDashboard JS-Button/code.js', 'u:dev:MediaWiki:EditBio/code.js', 'u:dev:MediaWiki:Translator/Translator.js', 'u:dev:MediaWiki:PurgeButton/code.js', 'u:dev:MediaWiki:MassProtect/code.js', 'u:dev:MediaWiki:BackToTopButton/code.js', 'u:dev:InputUsername/code.js', 'u:dev:BackToTopButton/code.js',

// ...	] });

// AdvancedQuoting 3.2 // License: WTFPL // HTML5 || GTFO //3.1 new msg edit api used //3.0 msg edit api used //2.8 new design supported now //2.5: article comments are supported now. and user comments. and ie. //will NOT work on ie. ever. //ever is gone. works on ie.

(function ($) {   if ((window.nQuoteSettings || {}).version) return; //multi protection    window.nQuoteSettings = $.extend(true, window.nQuoteSettings, {version: 3.3});    //settings    var urlVars = $.getUrlVars,        settings = window.nQuoteSettings;    settings = $.extend(true, settings, { //debug mode debug: urlVars.debug || (typeof(settings.debug) !== 'undefined' ? settings.debug : false), //language override lang: urlVars.uselang || settings.lang || mw.config.get('wgUserLanguage'), //article comments articleCommentFeature: typeof(settings.articleCommentFeature) !== 'undefined' ? settings.articleCommentFeature : true, quoteStyle: typeof(settings.quoteStyle) !== 'undefined' ? settings.quoteStyle : '', //static button class qsButtonClass: settings.qsButtonClass || 'nquoteClass', //floating buttons style qfButtonStyle: typeof(settings.qfButtonStyle) !== 'undefined' ? settings.qfButtonStyle : 'display:none; position:absolute; z-index:999;', //floating button name qfButtonName: settings.qfButtonName || 'nquoteFloatingButton', //ms. 0=forever qfButtonHideInterval: typeof(settings.qfButtonHideInterval) !== 'undefined' ? settings.qfButtonHideInterval : 3000, //removable events namespace rNamespace: settings.rNamespace || '.nRemovable', //min sel len. if lesser then full msg will be marked for quoting minSelectionLength: typeof(settings.minSelectionLength) !== 'undefined' ? settings.minSelectionLength : 3, //do not show floating button if lesser minSelection4Float: typeof(settings.minSelection4Float) !== 'undefined' ? settings.minSelection4Float : 1, //is username a link (w\ ending extra space) or plain text usernameAsLink: typeof(settings.usernameAsLink) !== 'undefined' ? settings.usernameAsLink : true, //do not use static reply button. false for mobile clients staticButtonOverpass: typeof(settings.staticButtonOverpass) !== 'undefined' ? settings.staticButtonOverpass : true, //wanna use template 4 quotes? useQuoteTemplate: typeof(settings.useQuoteTemplate) !== 'undefined' ? settings.useQuoteTemplate : false, //quote template quoteTemplateName: settings.quoteTemplateName || 'nquote', //disabling cookie name. if true then script will do nothing doNotName: settings.doNotName || 'njustno', //disable script to run (if cookie unavailable) doNotValue: typeof(settings.doNotValue) === 'undefined' ? false : settings.doNotValue, //chkbox id/name qchkName: settings.qchkName || 'nQChkBox', //chkbox class qchkClass: settings.qchkClass || 'nQChkC', //chkbox style qchkStyle: typeof(settings.qchkStyle) !== 'undefined' ? settings.qchkStyle : '', //namespaces to work on       namespaces: settings.namespaces instanceof Array ? settings.namespaces : [] });   var nTranslations = {        // language list - start        en: {            quote: 'Quote',            check: 'Quotation'        },        ar: {            quote: 'اقتبس',            check: 'اقتباس'        },        be: {            quote: 'Цытаваць',            check: 'Цытаванне'        },        es: {            quote: 'Cita',            check: 'Cita'        },        fr: {            quote: 'Citation',            check: 'Citation'        },        ru: {            quote: 'Цитировать',            check: 'Цитирование'        },        uk: {            quote: 'Цитувати',            check: 'Цитування'        },        // language list - stop    };    nTranslations = nTranslations[settings.lang] || nTranslations[mw.config.get('wgContentLanguage')] || nTranslations.en;    var n_Namespace = mw.config.get('wgNamespaceNumber'),        nNamespaces = [0, 500, 1201].concat(settings.namespaces), escapes = {},//escaped strings: id: guid, value: string nbShouldIKillMyself = nShouldIStopNow, log = function { if (!settings.debug) return; var a = [].slice.call(arguments); a.unshift('naq'); console.log.apply(this, a); };//log window.nQuoteSettings = settings;// throw settings back to window

if (nNamespaces.indexOf(n_Namespace) < 0) { log('wrong namespace. exit', n_Namespace, nbShouldIKillMyself, settings.debug); return; }//if wrong namespace

if (!(window.fng || {}).ngMsgEditAPI || !(window.fng || {}).ngMsgEditAPI.version) { importArticles({type:'script', articles: ['u:dev:MediaWiki:MsgEditApi.js']}); }

function gguid { return ("00000000" + (Math.random * Math.pow(36, 6) << 0).toString(16)).slice(-8); }//gguid

function escapeRegExp(str) { return str.replace(/([.*+?^=!:${}|\[\]\/\\])/g, "\\$1"); } //escapeRegExp

function escapeText(str, patterns) { var pats = patterns ? $.isArray(patterns) ? patterns : [patterns] : [], s = str; pats.push(/\{\{[\s\S]*?\}\}/gm);//templates for (var i = 0, ra; i < pats.length; i++) { ra = s.match(pats[i]) || []; for (var i1 = 0, r; i1 < ra.length; i1++) { r = {id: gguid, value: ra[i1]}; escapes[r.id] = r.value; s = s.replace(pats[i], r.id); }//for i1 (matches) }//for i (patterns) return s;   }//escapetext function unescapeText(str) { var s = str, s1 = '', esca = $.extend({}, true, escapes); $.each(esca, function(k, v) {           s1 = s.replace(k, v);            //if replacement actually made (esc is found and restored)            if (s !== s1) {                delete(escapes[k]);            }            s = s1;        });//each escapes return s;   }//unescapetext

function nShouldIStopNow { //use string below to prevent the script running //document.cookie=settings.doNotName+'='+'true;'+'path=/;'+'expires='+(new Date(new Date.setMonth(new Date.getMonth+12))).toUTCString; if ($.cookies.test) { var nck = $.cookies.get(settings.doNotName); if (nck && (nck == 'true')) { return true; }       } else { log('ShouldIStopNow. cookies are not supported. return sikm || donotvalue'); return settings.doNotValue || (typeof(nbShouldIKillMyself) === 'undefined' ? false : nbShouldIKillMyself); }       return settings.doNotValue || false; } //nShouldIStopNow

$(function {        //$(document).ready        //edit api        var neditApi = null;        var nTimerInterval = 100;        var nQFBHI = null; //qfbutton hiding timer        var nLastClickEvent = 0; //mouseup->click collision prevention        var nLastClickEventLimit = 1000; //ignores click events for n ms        var nActiveMessage = null;        var nSelectedText = '';        var nbMobile = false; //is mobile client.        var nNamespace = 0; //active namespace. 1-forum, 2-wikia article/blog

log('doc.ready');

function naddQB2FHandler(npiTargetClass) { //add handler 2 static quote button. forum if ((!npiTargetClass) || (npiTargetClass.length < 1)) npiTargetClass = '.nquoteClass'; log('addQB2FH class:', npiTargetClass); $('body').on('click' + settings.rNamespace, npiTargetClass, function {                var nText = neditApi.getMessage;                var selectedText = ngetSelectedText(this);                log('addQB2FH this, seltext', this, selectedText);                if (selectedText === null) {                    return;                }                var $MEW = $(this).closest('.MiniEditorWrapper');                var username = nGetUsername($MEW);//$(this).parents('.MiniEditorWrapper').find('.edited-by').text.trim;                var msgid = nGetMsgId($MEW);                var quoteText = nCreateQuote(nText, settings.quoteStyle, username, selectedText.trim, msgid);                if (!nbMobile) {                    $('.replyBody').focus; //will not work on ie                }                neditApi.setMessage(quoteText);                //if (nsetMessage(quoteText)===null) window.alert('smth wrng in da wrld'); });

} //naddQB2FHandler

function naddQB2WAHandler(npiTargetClass) { //let event-oriented programming begins if ((!npiTargetClass) || (npiTargetClass.length < 1)) npiTargetClass = '.nquoteClass'; //add handler $('body').on('click' + settings.rNamespace, npiTargetClass, function {                var nText = neditApi.getMessage;                var selectedText = ngetSelectedText(this);                if (selectedText === null) {                    return;                }                var $MEW = $(this).closest('.comment');                var username = nGetUsername($MEW);//$(this).parents('.comment').data('user').trim;                var msgid = nGetMsgId($MEW);                var quoteText = nCreateQuote(nText, settings.quoteStyle, username, selectedText.trim, msgid);                neditApi.setMessage(quoteText);            }); } //naddQB2WAHandler

function naddSHandler2F { //add selection handler. forum log('addSHandler2F'); $('body').on('mouseup' + settings.rNamespace, 'li.message', function (e) {               if (e.which !== 1)                    return; //1-lmb, 2-mmb, 3-rmb                var t1 = ngetSelectionQuick || '';                var text = ngetSelectedText(e.target);                if (text && (t1.toString.trim.length > settings.minSelection4Float)) {                    nActiveMessage = $(e.target).parents('.MiniEditorWrapper');                    nSelectedText = text;                    nLastClickEvent = e.timeStamp;                    log('SHandler2F. ShowButton w p:', nActiveMessage, nSelectedText, nLastClickEvent);                   nShowButton(e);                    return;                } else {                    nHideButton;                }            }); //mouseup //add mouseclick handler. button hiding purposes $('body').on('click' + settings.rNamespace, function (e) {               if (((e.timeStamp - nLastClickEvent) > nLastClickEventLimit) || (e.which != 1))                    nHideButton;            }); //keydown handler. button hiding 4 $('body').on('keydown' + settings.rNamespace, nHideButton); return; } //naddSHandler2F

function naddSHandler2WA { //add selection handler. wikia article log('addSHandler2WA'); $('body').on('mouseup' + settings.rNamespace, '#article-comments-ul.comments', function (e) {               if (e.which !== 1)                    return; //1-lmb, 2-mmb, 3-rmb                var t1 = ngetSelectionQuick || '';                var text = ngetSelectedText(e.target, 2);                if (text && (t1.toString.trim.length > settings.minSelection4Float)) {                    nActiveMessage = $(e.target).parents('.comment');                    nSelectedText = text;                    nLastClickEvent = e.timeStamp;                    log('SHandler2WA. ShowButton w p:', nActiveMessage, nSelectedText, nLastClickEvent);                   nShowButton(e);                    return;                } else {                    nHideButton;                }            }); //mouseup return; } //naddSHandler2WA function nHidingHandler (state) { //mouse/keydown handlers. button hiding purposes log('quote. hh.state', state); if (state) { $('body').on('click' + settings.rNamespace, nhh_helper); $('body').on('keydown' + settings.rNamespace, nHideButton); } else { $('body').off('click' + settings.rNamespace, nhh_helper); $('body').off('click' + settings.rNamespace, nHideButton); }//if state }//nhidinghandler function nhh_helper (e) { //hiding helper if (((e.timeStamp - nLastClickEvent) > nLastClickEventLimit) || (e.which != 1)) nHideButton; }//hh_click function nCreateButton { //create button. 1-forum, 2-wikia article log('CreateButton. Target:', nNamespace); var ncb = $(' ', {                   type: 'button',                    class: 'nquoteFloatingClass',                    id: settings.qfButtonName,                    name: settings.qfButtonName,                    style: settings.qfButtonStyle,                    text: nTranslations.quote                }); $(ncb).appendTo($('body')); switch (nNamespace) { case 1: log('CreateButton. add QFB2F_click'); $('#' + settings.qfButtonName).on('click' + settings.rNamespace, nQFB2F_click); break; case 2: log('CreateButton. add QFB2WA_click'); $('#' + settings.qfButtonName).on('click' + settings.rNamespace, nQFB2WA_click); break; default: log('CreateButton. switch:default. Target:', nNamespace); $('#' + settings.qfButtonName).on('click' + settings.rNamespace, nQFB2F_click); break; }           //});        } //nCreateButton

function nShowButton(npie) { log('ShowButton. ', npie.pageX, npie.pageY); $('#' + settings.qfButtonName).css({               left: npie.pageX,                top: npie.pageY            }); $('#' + settings.qfButtonName).show; if (settings.qfButtonHideInterval > 0) { if (nQFBHI !== null) clearInterval(nQFBHI); nQFBHI = window.setInterval(function {                        log('qfbutton hiding timer fired is.', nQFBHI);                        window.clearInterval(nQFBHI);                        nQFBHI = null;                        nHideButton;                    }, settings.qfButtonHideInterval); }       } //nShowButton

function nHideButton { log('HideButton'); if (nQFBHI !== null) { log('HideButton.qfbhi:', nQFBHI); window.clearInterval(nQFBHI); nQFBHI = null; }           $('#' + settings.qfButtonName).hide; nSelectedText = ''; nActiveMessage = null; } //nHideButton

function nQFB2F_click(npie) { // quote button. forum. click log('QFB2F_click'); if ((nSelectedText === ) || (nSelectedText.trim === )) { nHideButton; log('QFB2F_click. SelectedText=null. return'); return; }           log('QFB2F_click. getMessage'); var nText = neditApi.getMessage; log('QFB2F_click. GetUsername. msg:', nText); var username = nGetUsername($(nActiveMessage)); var msgid = nGetMsgId($(nActiveMessage)); log('QFB2F_click. CreateQuote.', username, msgid); var quoteText = nCreateQuote(nText, settings.quoteStyle, username, nSelectedText.trim, msgid); log('QFB2F_click. Quote:', quoteText); $('.replyBody').focus; //will not work on ie           log('QFB2F_click. setMessage'); neditApi.setMessage(quoteText); log('QFB2F_click. HideButton'); nHideButton; } //nQFB2F_click

function nQFB2WA_click(npie) { // quote button. wikia article. click log('QFB2WA_click'); if ((nSelectedText === ) || (nSelectedText.trim === )) { nHideButton; log('QFB2WA_click. SelectedText=null. return'); return; }           log('QFB2WA_click. getMessage'); var nText = neditApi.getMessage; log('QFB2WA_click. GetUsername. msg:', nText); var username = nGetUsername($(nActiveMessage)); var msgid = nGetMsgId($(nActiveMessage)); log('QFB2WA_click. CreateQuote. username:', username); var quoteText = nCreateQuote(nText, settings.quoteStyle, username, nSelectedText.trim, msgid); log('QFB2WA_click. Quote:', quoteText); $('.replyBody').focus; //will not work on ie           log('QFB2WA_click. setMessage'); neditApi.setMessage(quoteText); log('QFB2WA_click. HideButton'); nHideButton; } //nQFB2WA_click

function naddQB2F { //add quote button. forum log('addQB2F', window.nQButtonExist); log('addQB2F. addSHandler'); naddSHandler2F; log('addQB2F. SBO:', settings.staticButtonOverpass); if (settings.debug || nbMobile || (!settings.staticButtonOverpass)) { //sorry, mario, but your button is in another castle $(' ', {                   type : 'button',                    class : settings.qsButtonClass,                    text : nTranslations.quote                }) .appendTo('.msg-toolbar .buttonswrapper .buttons'); naddQB2FHandler('.' + settings.qsButtonClass); }       } //naddQB2F

function naddQB2WA { //add quote button. wikia article log('addQB2WA', window.nQButtonExist); //shoulda w8 4 comments. x10 timer interval. var nQB2WAInterval = null; //4 paranoid java compilers //if mobile. fixed probably if (settings.debug || nbMobile || (!settings.staticButtonOverpass)) { log('addQB2WA. set interval'); nQB2WAInterval = setInterval(function {                        //w8 4 comments                        if ($('.WikiaArticleComments').find('.comment').length > 0) {                            clearInterval(nQB2WAInterval);                            var nqsb = $(' ', { type: 'button', class: settings.qsButtonClass + ' actionButton wikia-button', text: nTranslations.quote });                           log('addQB2WA. Interval. Comment is ready. addQB2WAButton');                           $(nqsb).prependTo('.WikiaArticleComments .comment .buttons');                            naddQB2WAHandler('.' + settings.qsButtonClass);                        }                    }, nTimerInterval * 10); }           //w8 4 comments log('addQB2WA. set interval'); var nQFB2WAInterval = setInterval(function {                    if ($('.WikiaArticleComments').find('.comment').length > 0) {                        clearInterval(nQFB2WAInterval);                        log('addQB2WA. Interval. Button is ready. addSHandler2WA');                       naddSHandler2WA;                    }                }, nTimerInterval * 10);

} //naddQB2WA

function naddQButton { //add quote button. 1-forum, 2-wikia article log('addQButton. Target:', nNamespace); switch (nNamespace) { case 1: log('addQButton. addQB2F'); naddQB2F; break; case 2: log('addQButton. addQB2WA'); naddQB2WA; break; default: log('addQButton. switch:default. Target:', nNamespace); naddQB2F; break; }       } //naddQButton

function ngetSelectedText(target) { //get selected text. additional targets //selected text || full message log('getSelectedText', target, nNamespace); var nret = null; switch (nNamespace) { case 1: nret = ngetSelectedTextF(target); break; case 2: log('getSelectedText. switching 2 wa'); nret = ngetSelectedTextWA(target); break; default: nret = ngetSelectedTextF(target); }

return nret; } //ngetSelectedText

function ngetSelectedTextF(target) { //get selected text. forum log('getSelectedTextF. Target:', target); var selection; var selectedElement; var selectedText = ''; var $MEW = $(target).closest('.MiniEditorWrapper'); if (nbMobile) { log('getSelectedTextF. mobile. quote full msg'); if ($MEW.find('.msg-body').parent) { //it works and renders nested quotes. sometimes selectedText = $MEW.find('.msg-body').parent.html; log('getSelectedTextF. qfm.mew.msg-body.innerhtml:', selectedText); } else { //if sometimes not happen selectedText = $MEW.find('.msg-body').text; log('getSelectedTextF. qfm.mew.msg-body.text:', selectedText); }               return selectedText; }           if (window.getSelection) { selection = window.getSelection; } else if (document.getSelection) { selection = document.getSelection; } else { log('getSelectedText. no selection found. return'); return null; }

if (selection.rangeCount > 0) { selectedElement = selection.getRangeAt(0).startContainer.parentNode; } // else return null; if ((selectedElement && $MEW.find($(selectedElement)).length) && (selection.toString.length > settings.minSelectionLength)) { selectedText = selection.toString; log('getSelectedTextF. s:', selectedText.length, selectedText); return selectedText; } else { //quote full msg log('getSelectedTextF. full msg', $MEW); selectedText = $MEW.find('.msg-body').html; return selectedText; }       } //ngetSelectedTextF

function ngetSelectedTextWA(target) { //get selected text. wikia article log('getSelectedTextWA. Target:', target); var selection; var selectedElement; var selectedText = ''; if (nbMobile) { log('getSelectedTextWA. mobile'); if ($(target).parents('.comment').find('.WikiaArticle').parentNode) { //it works and renders nested quotes. sometimes selectedText = $(target).parents('.comment').find('.WikiaArticle').parentNode.innerHTML; log('getSelectedTextWA. wa.innerhtml', selectedText); } else { //if sometimes not happen selectedText = $(target).parents('.comment').find('.WikiaArticle').text; log('getSelectedTextWA. wa.text', selectedText); }               return selectedText; }           if (window.getSelection) { selection = window.getSelection; } else if (document.getSelection) { selection = document.getSelection; } else { log('getSelectedTextWA. no selection found. return'); return null; }

if (selection.rangeCount > 0) { selectedElement = selection.getRangeAt(0).startContainer.parentNode; } // else return null; if ((selectedElement && $(target).parents('.comment').find($(selectedElement)).length) && (selection.toString.length > settings.minSelectionLength)) { selectedText = selection.toString; return selectedText; } else { //quote full msg log('getSelectedTextWA. full msg'); if ($(target).parents('.comment').find('.WikiaArticle').parentNode) { //it works and renders nested quotes. sometimes selectedText = $(target).parents('.comment').find('.WikiaArticle').parentNode.innerHTML; } else { //if sometimes not happen selectedText = $(target).parents('.comment').find('.WikiaArticle').text; }               return selectedText; }       } //ngetSelectedTextWA

function ngetSelectionQuick { var selection=null; if (window.getSelection) { selection = window.getSelection; } else if (document.getSelection) { selection = document.getSelection; } else { return null; }           if (selection.rangeCount > 0) return selection; return null; } //nGetSelectionQuick

function nGetUsername(npiContext, npiLink) { //get username. 1-active message context, 2-username as link override (source-mode link issue) if (npiLink === null) npiLink = true; if (!npiContext) npiContext = $(nActiveMessage); log('GetUsername.', npiContext, npiLink); var $a, nuname = '', nulink = ''; switch (nNamespace) { case 1: $a = npiContext.find('.edited-by a:first'); nuname = { name: $a.text.trim, link: $a.attr('href').replace(/(.*?\/wiki\/)(.*)/, '$2'), };               break; case 2: nuname = { name: npiContext.data('user'), link: 'user:' + npiContext.data('user'), };               break; default: nuname = { name: npiContext.data('user'), link: 'user:' + npiContext.data('user'), };           }            return nuname; } //nGetUsername function nGetMsgId (npiContext) { //get msgid/link if (!npiContext) npiContext = $(nActiveMessage); log('getmsgid context', npiContext); var nid = '', $nlink = npiContext.find('.permalink'); if (!$nlink.length) return ''; nid = $nlink.attr('href').replace(/.*#/, ''); if (nid === $nlink.attr('href')) { nid = nid.replace(/.*\//, ''); } else { nid = '#' + nid; }           log('getmsgid id', nid); return nid; }//nGetMsgId

function nCreateQuote(npiM, npiQS, npiU, npiT, npiMsgId) { //create quote. 1-prev message, 2-quote style, 3-username: {name, link}, 4-text, 5-msgid if (settings.useQuoteTemplate) { //escape templates npiT = escapeText(npiT); //strip pipe (|) chars npiT = npiT.replace('|', '|'); //unescape templates npiT = unescapeText(npiT); var text = (npiM ? npiM : '') + '';               return text; }           var $quote; $quote = $(' ', {               class: 'aquote',                style: npiQS            }); $quote.data('rte-washtml', '1'); $quote .append($(' ', { class: 'aquote-user' }).text(settings.usernameAsLink ?  + npiU.name +  : npiU.name)) .append($(' ', { class: 'aquote-msgid', style: 'float:right;' }).text(npiMsgId.length ?  + decodeURIComponent(npiMsgId) +  : '')) .append($(' ', { class: 'aquote-msg' }).html(npiT)); return npiM + $quote.get(0).outerHTML + ' '; } //nCreateQuote

function nCreateQChkbox { //create quotation toggler var $nlabel, $ninput; var $li = $(''); $nlabel = $(' ', {               class: settings.qchkClass,                style: settings.qchkStyle,                text: nTranslations.check            }); $ninput = $(' ', {               type: 'checkbox',                name: settings.qchkName,                id: settings.qchkName,                class: settings.qchkClass,                style: settings.qchkStyle            }); if (!nbShouldIKillMyself) $ninput.attr('checked', 'checked'); $nlabel.prepend($ninput); $li.append($nlabel); $li.appendTo('.page-header__contribution-buttons .wds-list:first'); $('#' + settings.qchkName).on('click', nQChkboxClick); } //nCreateQChkBox

function nQChkboxClick { //qchkbox event handler log('QChkboxClick'); //disable chkbox - job in progress. sync is presumed $('#' + settings.qchkName).prop('disabled', true); if ($('#' + settings.qchkName).prop('checked')) { nbShouldIKillMyself = false; nSetQCookie(false); //enable script the nResurrectMyself; //bring me to life } else { nbShouldIKillMyself = true; nSetQCookie(true); //disable script the nKillMyself; //remove me           } //enable chkbox - job done, ready to operate $('#' + settings.qchkName).removeProp('disabled'); } //nQChkboxClick

function nSetQCookie(npi) { log('SetQCookie:', npi); if ($.cookies.test) { document.cookie = settings.doNotName + '=' + npi + ';' + 'path=/;' + 'expires=' + (new Date(new Date.setMonth(new Date.getMonth + 12))).toUTCString; } else { log('SetCookie. cookies not supported are'); }       } //nSetQCookie

function nKillMyself { //cleaning tool log('KillMyself:'); //remove handlers by namespace $('*').off(settings.rNamespace); //remove buttons $('.' + settings.qsButtonClass).remove; //$('.'+settings.qchkClass).remove; $('#' + settings.qfButtonName).remove; } //nKillMyself

function nResurrectMyself { //turn up the buttons log('ResurrectMyself'); nmain({npi1stRun: false}); } //nResurrectMyself

function nmain(arg) { //main //preparing enable\disable feat w\o reloading //todo: save setting(s) 4 un- or decooked browsers(through mw.user.options. probably) arg = arg || {}; console.log('naq main. version:', settings.version, arg); //make sure the script running is           if (typeof(arg.npi1stRun) === 'undefined') arg.npi1stRun = true; //default parameters are not supported yet. es2015 :\ //add enabling\disabling checkbox. only once if (arg.npi1stRun) nCreateQChkbox; if (settings.doNotValue || nbShouldIKillMyself) { log('disabled', n_Namespace, nbShouldIKillMyself, settings.debug); if (!settings.debug) return; }//if disabled if (navigator.userAgent.indexOf('Mobile') != -1) { nbMobile = true; //it means falling to ie + additional restrictions log('main. mobile'); }           //ie-specific. ie10=mozilla+trident. if (nbMobile || ((navigator.userAgent.indexOf('Mozilla') != -1) && (navigator.userAgent.indexOf('Trident') != -1))) { log('main. Browser: IE'); //settings.usernameAsLink = false; }           switch (n_Namespace) { case 0: //wikia article log('main. wikia article'); nNamespace = 2; break; case 500: //blog = wikia article log('main. blog'); nNamespace = 2; break; case 1201: //forum log('main. forum'); nNamespace = 1; break; default: //undefined nNamespace = 0; break; }           //if article and article comment feature disabled is            if ((nNamespace === 2) && (!settings.articleCommentFeature)) return; //get edit api neditApi = neditApi || arg.editapi; //create floating button nCreateButton; //add floating and static buttons naddQButton; } //nmain

//and here we go       mw.hook('nmsgeditapi.ready').add(function (e) {            log('mea.ready', e);            nmain({editapi: e});        }); }); //$(document).ready }(jQuery));

require(['wikia.ui.factory'], function(ui) {   'use strict';    importArticle({ type: 'script', article: 'u:dev:MediaWiki:I18n-js/code.js' }, {       type: 'style', article: 'u:dev:MediaWiki:LastEdited.css' });

/**    * Main object * @class lastEdited */   var lastEdited = { // Cached mw.config values config: mw.config.get([           'stylepath',            'skin',            'wgAction',            'wgArticleId',            'wgFormattedNamespaces',            'wgIsMainPage',            'wgNamespaceNumber',            'wgPageName',            'wgUserGroups',            'wgUserName'        ]), // Configuration options options: $.extend({           avatar: true,            avatarsize: 15,            size: true,            diff: true,            diffModal: true,            comment: true,            newpage: true,            time: 'timeago',            position: {                 element: ,                 method:             },            namespaces: {                exclude: [-1, 1201, 2001]            },            pages: []        }, window.lastEdited), // If the user can rollback edits canRollback: /(bureaucrat|sysop|helper|vstf|staff|content-moderator|rollback)/.test(mw.config.get('wgUserGroups').join(' ')), /**        * Initializes everything */       init: function { if (lastEdited.shouldRun) { window.lastEditedLoaded = true; lastEdited.insert; mw.hook('dev.i18n').add(function(i18no) {                   $.when( lastEdited.fetch, i18no.loadMessages('LastEdited'), ui.init(['modal']), mw.loader.using('mediawiki.action.history.diff') ).then(lastEdited.render);               }); }       },        /**         * Checks whether the script should run further or not * @return {Boolean} If the script should run further */       shouldRun: function { var allowed = Object.keys(lastEdited.config.wgFormattedNamespaces).map(Number), ns = lastEdited.options.namespaces; if (ns && ns.exclude instanceof Array) { allowed = allowed.filter(function(elem) {                   return ns.exclude.indexOf(elem) < 0;                }); }           return !$.getUrlVar('diff') && !$.getUrlVar('oldid') && allowed.indexOf(lastEdited.config.wgNamespaceNumber) !== -1 && lastEdited.options.pages.indexOf(lastEdited.config.wgPageName) === -1 && !lastEdited.config.wgIsMainPage && lastEdited.config.wgAction === 'view' && !window.lastEditedLoaded && lastEdited.config.wgArticleId !== 0; },       /**         * Inserts the placeholder for last edit information */       insert: function { var $loader = $(' ', {               id: 'lastEdited',                'class': 'lastEdited'            }).append(                $(' ', { id: 'lastEdited-loading', src: lastEdited.config.stylepath + '/common/images/ajax.gif' })           );            if (lastEdited.config.skin === 'oasis') { var pos = lastEdited.options.position; if (pos.element && pos.method) { var $el = $(pos.element), m = pos.method; if ($el.length && (m === 'append' || m === 'prepend')) { $el[m]($loader); }               } else { $loader.insertAfter('#PageHeader .page-header__title, .UserProfileActionButton'); }           } else { $loader.insertBefore('#bodyContent'); }           lastEdited.$content = $loader; mw.hook('LastEdited.inserted').fire($loader); },       /**         * Fetches last edit information from the API * @returns {jQuery.Deferred} A Promise-like object */       fetch: function { var query = { action: 'query', titles: lastEdited.config.wgPageName, prop: 'revisions', rvprop: 'timestamp|user|userid|size|parsedcomment|flags', rvlimit: 2, rvdiffto: 'prev', format: 'json' };           if (lastEdited.canRollback) { query.rvtoken = 'rollback'; }           return $.get(mw.util.wikiScript('api'), query); },       /**         * Renders last edited information * @param {Object} data Edit information obtained from the API * @param {Object} i18n I18N object generated by I18n-js * @param {Object} modal Modal generator obtained from UI factory */       render: function(data, i18n, modal) { if (lastEdited.options.lang) { i18n.useLang(lastEdited.options.lang); } else { i18n.useUserLang; }           data = data[0].query.pages[lastEdited.config.wgArticleId].revisions; if (!data[1] && !lastEdited.options.newpage) { lastEdited.$content.remove; return; }           var prev = data[1]; data = data[0]; lastEdited.$content.html(''); ['UserTime', 'Diff', 'Minor', 'Comment', 'Size'].forEach(function(el) {               lastEdited.$content.append.apply(lastEdited.$content, lastEdited['render' + el](data, i18n, prev));            }); // In case the user doesn't have an avatar $('#lastEdited img').error(function {               $(this).attr('src', 'https://images.wikia.nocookie.net/messaging/images/1/19/Avatar.jpg');            }); lastEdited._i18n = i18n; lastEdited._data = data; lastEdited._modal = modal; mw.hook('LastEdited.render').fire(lastEdited.$content); },       /**         * Returns HTML for a link to a page * containing a user's username * Utility function for renderUserTime * @returns {String} HTML for an  tag */       userLink: function(prefix, user, text) { return mw.html.element('a', { href: mw.util.getUrl(prefix + user) }, text); },       /**         * Renders user and time links * @param {Object} data Edit information obtained from the API * @param {Object} i18n I18N object generated by I18n-js * @returns {Array} Parts to append to last edited information */       renderUserTime: function(data, i18n) { // Build user links var user = data.user, links = lastEdited.userLink('User:', user, user) + ' (' +                   lastEdited.userLink('User talk:', user, i18n.msg('talk').plain) +                    ' | ' +                    lastEdited.userLink('Special:Contributions/', user, i18n.msg('contribs').plain);            if (/(bureaucrat|sysop|helper|vstf|staff|custodian)/.test(lastEdited.config.wgUserGroups.join(' '))) {                links += ' | ' + lastEdited.userLink('Special:Block/', user, i18n.msg('block').plain);            }            if (lastEdited.options.avatar) {                links = mw.html.element('img', { src: 'https://services.fandom.com/user-avatar/user/' + data.userid + '/avatar', width: lastEdited.options.avatarsize, height: lastEdited.options.avatarsize }) + ' ' + links;           }            links += ') '; // Build time var $time = $(' ', {               'class': 'lastEdited-timeago',                title: data.timestamp            }); if (lastEdited.options.time === 'timestamp') { var date = new Date(data.timestamp).toString; if (lastEdited.options.timezone && lastEdited.options.timezone === 'UTC') { date = new Date(data.timestamp).toUTCString; }               if (lastEdited.options.timezone && lastEdited.options.timezone === 'locale') { date = new Date(data.timestamp).toLocaleString; $time.text(date); }               else { $time.text(date.slice(0, 3) + ', ' + date.slice(4, 16) + ', ' + date.slice(17, 26)); }           } else { $time.timeago; }           return [ i18n.msg('lastEdited').escape .replace('$1', links) .replace('$2', $time.prop('outerHTML')) ];       },        /**         * Renders the diff link * @param {Object} data Edit information obtained from the API * @param {Object} i18n I18N object generated by I18n-js * @returns {Array} Parts to append to last edited information */       renderDiff: function(data, i18n) { if (lastEdited.options.diff && data.diff.from) { var link = $('', {                   id: 'lastEdited-diff-link',                    href: '?diff=' + data.diff.to,                    text: i18n.msg('diff').plain,                    title: 'Special:Diff/' + data.diff.to                }); if (lastEdited.options.diffModal) { link.attr('data-disable-quickdiff', ''); link.click(function(e) {                       e.preventDefault;                        lastEdited.generateModal(lastEdited._i18n, lastEdited._data, lastEdited._modal);                    }); }               return [ ' (',                   link,                    ')' ];           }            return []; },       /**         * Renders the "m" sign next to minor edits * @param {Object} data Edit information obtained from the API * @param {Object} i18n I18N object generated by I18n-js * @returns {Array} Parts to append to last edited information */       renderMinor: function(data, i18n) { if (data.minor === '') { return [ ' ',                   $(' ', {                        id: 'lastEdited-minor',                        text: '[' + i18n.msg('minor').plain + ']'                    }) ];           }            return []; },       /**         * Renders the last edit summary used * @param {Object} data Edit information obtained from the API * @param {Object} i18n I18N object generated by I18n-js * @returns {Array} Parts to append to last edited information */       renderComment: function(data, i18n) { var comment = data.parsedcomment; if (lastEdited.options.comment && comment) { return [ ' ',                   i18n.msg('comment').escape, ': ',                   comment.indexOf('Created page with') === -1 ? comment : i18n.msg('created').escape ];           }            return []; },       /**         * Renders the size of the last diff * @param {Object} data Edit information obtained from the API * @param {Object} i18n I18N object generated by I18n-js * @param {Object} prev Information about the previous edit from the API * @returns {Array} Parts to append to last edited information */       renderSize: function(data, i18n, prev) { if (!lastEdited.options.size) { return []; }           var arr = [ ' ',               i18n.msg('size').escape, ': ',               data.size, ' ',               i18n.msg('bytes').escape ];           if (prev) { var bytes = data.size - prev.size, classes = 'mw-plusminus-' + (bytes > 0 ?                       'pos' :                        bytes < 0 ?                            'neg' :                            'null'); if (Math.abs(bytes) > 500) { classes += ' lastEdited-diff-major'; }               arr.push(                    ' ',                    $(' ', { text: '(' + (bytes > 0 ? '+' : '') + bytes.toString.replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ')', 'class': classes })               );            }            return arr; },       /**         * (Re)generates the diff modal * @param {Object} data Edit information obtained from the API * @param {Object} i18n I18N object generated by I18n-js * @param {Object} modal Modal generator obtained from UI factory */       generateModal: function(i18n, data, modal) { var config = { vars: { id: 'lastEdited-diff', size: 'large', title: i18n.msg('changes').escape + ': ' + lastEdited.config.wgPageName.replace(/_/g, ' '), content: ' ' + ' ' +                            ' ',                    buttons: [ {                           vars: { value: i18n.msg('cancel').plain, data: [{ key: 'event', value: 'close' }]                           }                        },                        {                            vars: { value: i18n.msg('link').plain, classes: ['normal', 'primary'], data: [{ key: 'event', value: 'link' }]                           }                        },                        {                            vars: { value: i18n.msg('undo').plain, classes: ['normal', 'primary'], data: [{ key: 'event', value: 'undo' }]                           }                        }                    ]                },                confirmCloseModal: function { lastEdited.modal = null; return true; }           };            if (lastEdited.canRollback && lastEdited.config.wgUserName !== data.user) { config.vars.buttons.push({                   vars: {                        value: i18n.msg('rollback').plain,                        classes: ['normal', 'primary'],                        data: [{                            key: 'event',                            value: 'rollback'                        }]                    }                }); }           modal.createComponent(config, function(diffModal) {                diffModal.bind('link', function { diffModal.trigger('close'); window.open(mw.util.getUrl('', { diff: data.diff.to                   }), '_blank'); });               diffModal.bind('undo', function { diffModal.trigger('close'); window.open(mw.util.getUrl(lastEdited.config.wgPageName, { action: 'edit', undoafter: data.diff.from, undo: data.diff.to                   }),                    '_blank'); });               diffModal.bind('rollback', function { $.post(mw.util.wikiScript('api'), {                       action: 'rollback',                        title: lastEdited.config.wgPageName,                        user: data.user,                        token: data.rollbacktoken,                        format: 'json'                    }).done(function(d) {                        if (!d.error) {                            window.location.reload;                        }                    }); });               lastEdited.modal = diffModal;                lastEdited.modal.show;            }); }   };    lastEdited.init; });

// /* jshint browser:true jquery:true laxbreak:true smarttabs:true */ /* global mediaWiki */ (function(window, $, mw) {   'use strict';    var config = mw.config.get([ 'wgAction', 'wgNamespaceNumber', 'wgTitle', 'wgUserGroups', 'wgUserName' ]), groups = config.wgUserGroups.join(' ');   if (config.wgNamespaceNumber === 1202) {        $('#ca-talk').remove;        return;    } else if ( config.wgTitle.indexOf('/') !== -1 || config.wgNamespaceNumber !== 1200 || !(           config.wgUserName === config.wgTitle ||            /sysop|threadmoderator|vstf|helper|staff/.test(groups)        ) || config.wgAction !== 'edit' || window.WallGreetingButtonLoaded ) {       return;    }    window.WallGreetingButtonLoaded = true;    function init(i18n) {        i18n.useUserLang;        var params = {            url: new mw.Title(config.wgTitle, 1202).getUrl,            wallUrl: new mw.Title(config.wgTitle, 1200).getUrl        };        ['editGreeting', 'history', 'wallHistory', 'delete', 'protect', 'raw'].forEach(function(el) { params[el] = i18n.msg(el).plain; });       $('#WikiaMainContentContainer').prepend(window.Mustache.render(            ' ' +                ' ' +                    ' ' +                        '' +                            '' +                                ' ' +                            ' ' +                            '  ' +                        '' +                        ' ' +                            '' +                                '' + ' ' + ' ' +                           ' ' +                            '' + '' + '</a></li>' + '</a></li>' + (                                       /sysop|content-moderator|vstf|helper|staff/.test(groups) ?                                            '</a></li>' +                                             (window.WallGreetingButtonProtect ? '</a></li>' : ) :                                                                               ) +                                     (                                        window.WallGreetingButtonRaw ?                                            '</a></li>' :                                        ''                                    ) + '</ul>' + ' ' +                       ' ' +                    ' ' +                ' ' +            ' ',            params ));   }    importArticle({        type: 'script',        article: 'u:dev:MediaWiki:I18n-js/code.js'    }); mw.hook('dev.i18n').add(function(i18no) {       $.when( i18no.loadMessages('WallGreetingButton'), mw.loader.using(['mediawiki.Title', 'wikia.mustache']) ).then(init);   }); })(window, jQuery, mediaWiki);

/* mw.loader.using('mediawiki.api', function {	//Exit if normal rollback links are present	if ($('.mw-rollback-link').length) return;	var conf = mw.config.get([ 'wgAction', 'wgCanonicalSpecialPageName', 'wgContentLanguage', 'wgPageName', 'wgUserLanguage', 'skin' ]),	i18n = {		en: {			rollback: "rollback",			description: "&quot;Rollback&quot; reverts edit(s) to this page of the last contributor in one click",			summary: "Reverted edits by $1 (talk | block) to last version by $2 (script)",			summaryShort: "Reverted edits by $1 (talk) to last version by $2 (script)",			editConflict: "Unable to rollback (edit conflict)",			contentFail: "Unable to rollback (failed to get page content)",			singleEditor: "Unable to rollback (no different editor found)",			revisionFail: "Unable to rollback (failed to get revisions)",			editFail: "Unable to rollback (failed to publish edit)",			success: "Rollback successful"		}	};	i18n = i18n[conf.wgUserLanguage] || i18n[conf.wgUserLanguage.split('-')[0]] || i18n[conf.wgContentLanguage] || i18n[conf.wgContentLanguage.split('-')[0]] || i18n.en; conf.API = new mw.Api; conf.token = mw.user.tokens.values.editToken; //History if (conf.wgAction == "history" && $('#pagehistory li').length > 1) $('#pagehistory li:first .mw-history-undo a').before(' ' + i18n.rollback + '</a> | '); //Contributions else if (conf.wgCanonicalSpecialPageName == "Contributions") { $('#mw-content-text ul').find('li').each(function {			if ($(this).find('.mw-uctop').length)				$(this).append(' [' + i18n.rollback + '</a>] ');		}); }	//Diffs else if (($.getUrlVar('diff') || $.getUrlVar('oldid')) && $('#differences-nextlink').length === 0) $('.mw-usertoollinks:last').after('   [' + i18n.rollback + '</a>] '); else return; mw.util.addCSS('.mw-custom-rollback-link a { cursor: pointer; }'); $('.mw-custom-rollback-link a').click(function {		getRevisionIdAndContent($(this).data('id'),$(this).data('user').replace(/_/g, " "));		$(this).parent.remove;	}); window.AjaxBlock = { blockReasons: { 'Vandalism': 'Vandalism', 'Spam': 'Spam', 'Repeated policy violations': 'Repeated violations', 'Sockpuppetry/Ban Evasion': 'Sockpuppetry', 'Moved to a new account': 'Moved account', 'Removing content/blanking pages': 'Page blanking', 'Inserting false information or nonsense': 'Gibberish', 'Intimidating behaviour/harassment/trolling': 'Troll/Harassment', 'Unacceptable username, avatar, or global masthead': 'Name/avatar', 'Under the legal age': 'COPPA', 'Failing to comply with the File Policy': 'File Policy', 'Posting/Discussing leaked content': 'Leaks' },   check: { creation: true, talk: true, autoBlock: true, override: true } };	function getRevisionIdAndContent(title,target) { conf.API.get({		action: 'query',		prop: 'revisions',		titles: title,		rvprop: 'user|ids',		rvlimit: 500000,		cb: new Date.getTime		}) .done(function(d) {			if (!d.error) {				var revisions;				for (var i in d.query.pages) {					revisions = d.query.pages[i].revisions;				}				var lastUser,				revId;				for (var j in revisions) {					if (revisions[j].user != target) {						lastUser = revisions[j].user; //remember last author						revId = revisions[j].revid; //get revision to revert to						break;					}				}				if (lastUser) {					conf.API.get({ action: 'query', prop: 'revisions', rvprop: 'content', revids: revId, cb: new Date.getTime })					.done(function(d) { if (!d.error) { var content = ""; //can be no content on page for (var i in d.query.pages) { if (d.query.pages[i].revisions) content = d.query.pages[i].revisions[0]["*"]; }							performRollback(title,content,target,lastUser); }						else outputError(i18n.contentFail + ': ' + d.error.code); })					.fail(function { outputError(i18n.contentFail); });				}				else					outputError(i18n.singleEditor);			}			else				outputError(i18n.revisionFail + ': ' + d.error.code);		}) .fail(function {			outputError(i18n.revisionFail);		}); }	function performRollback(page,text,user,user2) { var summary = i18n.summary.replace(/\$1/g,user).replace(/\$2/g,user2); conf.API.post({		action: 'edit',		title: page,		text: text,		summary: summary,		minor: true,		token: conf.token		}) .done(function(d) {			if (!d.error) {				new BannerNotification(i18n.success,'confirm').show;							}			else				outputError(i18n.editFail + ': ' + d.error.code);		}) .fail(function {			outputError(i18n.editFail);		}); }	function outputError(text) { switch (conf.skin) { case 'oasis': case 'wikia': new BannerNotification(text,'error').show; break; default: alert(text); break; }		} });
 * Rollback
 * @description Perform rollbacks without needing to be in the usergroup
 * @author Ozank

/** * !kick.js * * Allows use of !kick command in Special:Chat * @author: w:User:Slyst */ (function {   var config = mw.config.get([ 'wgCanonicalSpecialPageName', 'wgUserGroups' ]), i18n, hierarchy = window.KickHierarchy || [       'staff',        'sysop',        'helper',        'vstf',        'threadmoderator',        'chatmoderator'    ];    if ( config.wgCanonicalSpecialPageName !== 'Chat' || !/staff|helper|sysop|threadmoderator|chatmoderator/.test(config.wgUserGroups.join) ) {       return;    }    function inlineAlert(msg) {        var $entry = $('', { 'class': 'inline-alert', text: msg });       if ($('.Chat li').last.hasClass('inline-alert')) {            $entry.addClass('continued');        }        $('.Chat ul').append($entry);    }    function getHighestGroup(user) {        var min = 99;        user.get('groups').forEach(function(group) { var index = hierarchy.indexOf(group); if (index !== -1 && min > index) { min = index; }       });        return min;    }    function keydown(e) {        if (e.which !== 13 || $(this).val.substr(0, 5) !== '!kick') {            return;        }        e.preventDefault;        var username = $(this).val.substr(6),            user = mainRoom.model.users.findByName(username),            last = $('.Chat li').last.attr('data-user');        if (!user) {            inlineAlert( window.absentMessage ? window.absentMessage.replace(' ', username) : i18n.msg('absent', username).plain );           return;        }        if ( getHighestGroup(mainRoom.userMain) > getHighestGroup(user) && window.NoKickHigherUps ) {           inlineAlert(i18n.msg('higher', username).plain);            return;        }        mainRoom.kick({ name: username });       $(this).val('');    }    mw.hook('dev.i18n').add(function(i18no) { i18no.loadMessages('!kick').done(function (i18nd) {           i18n = i18nd;            $('[name="message"]').keydown(keydown);        }); });   importArticle({ type: 'script', article: 'u:dev:I18n-js/code.js' }); }); // Talk page button // Created by Lil' Miss Rarity // MIT OS License mw.loader.using(['mediawiki.api', 'mediawiki.Title']).then(function {   var config = mw.config.get([ 'wgArticleId', 'wgNamespaceNumber', 'wgPageName' ]);   if ( (window.TalkButtonNamespaces || [0]).indexOf(config.wgNamespaceNumber) === -1 || config.wgArticleId === 0 || window.TalkButtonLoaded ) {       return;    }    window.TalkButtonLoaded = true;    var title = new mw.Title(config.wgPageName);    title.namespace += 1;    var titleText = title.getPrefixedText;    new mw.Api.get({ action: 'query', titles: titleText, prop: 'info', meta: 'allmessages', inprop: 'revcount', ammessages: 'oasis-page-header-talk' }).done(function(d) { if (d.error) { return; }       var text = d.query.allmessages[0]['*'], pages = d.query.pages; if (!pages[-1]) { text += ' (' + pages[Object.keys(pages)[0]].revcount + ')'; }       $('').append(            $('', { 'class': 'TalkButtonBubble', href: mw.util.getUrl(titleText), id: 'ca-talk', text: text })       ).appendTo('.page-header__contribution-buttons .wds-list'); }); });

/* * !ban w:c:dev:!ban * * Allows to block from chat without using the usual ban modal * Syntax: !ban USER NAME for BAN DURATION because BAN REASON * Alt Syntax: !ban USER NAME|BAN DURATION|BAN REASON * @author: w:User:Dorumin */ (function {   var config = mw.config.get([ 'wgCanonicalSpecialPageName', 'wgUserName' ]), loaded = 0, i18n, wasDefault;   if ( config.wgCanonicalSpecialPageName !== 'Chat' || window['!BanLoaded'] ) {       return;    }    window['!BanLoaded'] = true;    [        'u:dev:MediaWiki:Chat-js.js',        'u:dev:MediaWiki:I18n-js/code.js'    ].forEach(function(s) { importArticle({ type: 'script', article: s }); });   // Taken and modified from w:c:dev:MediaWiki:QuickModTools/code.js.    function calcTime(s) {        if (s instanceof Number) {            return s;        }        var time = {},            i18n = {                second: 1,                minute: 60,                hour: 3600,                day: 86400,                week: 604800,                month: 2592000,                year: 31536000            },            m = s.toLowerCase.match(/(\d+|an?) (second|minute|hour|day|week|month|year)/g);        if (m === null && /never|infinite|indefinite|forever/i.test(s.toLowerCase)) {            return 31536000000;        } else if (m === null) {            wasDefault = true;            return window.defCBanDuration || 86400; // null        } else if ($.isArray(m)) {            // found match(es)            var i;            for (i in m) {                var a = m[i].split(' '); time[a[1]] = Number(a[0].replace(/an?/, '1')) * i18n[a[1]]; }           var timeCount = 0; for (i in time) { timeCount += time[i]; }           if (timeCount === 0) { wasDefault = true; return window.defCBanDuration || 86400; // equal to 0 seconds } else { return timeCount; }       } else { // no matches found - use default time wasDefault = true; return window.defCBanDuration || 86400; }   }    function keydown(e) { var $this = $(this), value = this.value; if (e.which === 13 && value.toLowerCase.substr(0, 5) === '!ban ') { e.preventDefault; var t = /\|/g.test(value) && !(                       / for | because (.+)?/gi.test(value) &&                        value.match(/ for | because (.+)?/gi).length === 2                    ) ? value.slice(5).split(/\|/g) : value.slice(5).split(/ for | because (.+)?/gi).filter(Boolean); $this.val(''); if (t[0] === config.wgUserName) { mainRoom.viewDiscussion.chatUL.append(                   $('', { 'class': 'inline-alert', text: i18n.msg('ban-you').plain })               );                mainRoom.viewDiscussion.scrollToBottom; return; }           mainRoom.socket.send(new models.BanCommand({ userToBan: t[0], time: calcTime(t[1] || window.defCBanDuration || ''), reason: t[2] || window.defCBanReason || i18n.msg('no-reason').plain }).xport); if (wasDefault) { mainRoom.viewDiscussion.chatUL.append(                   $('<li>', { 'class': 'inline-alert', text: i18n.msg('time-invalid').plain })               );                mainRoom.viewDiscussion.scrollToBottom; wasDefault = false; }       }    }    function init(i18na) { i18n = i18na; $('[name="message"]').keydown(keydown); }   function preload { if (++loaded === 2) { if (!mainRoom.userMain.attributes.isModerator) { return; }           window.dev.i18n .loadMessages('!ban') .then(init); }   }    mw.hook('dev.i18n').add(preload); mw.hook('dev.chat.render').add(preload); });

/** * Standard edit summaries * * see https://dev.wikia.com/wiki/Standard_Edit_Summary * for documentation and examples * * Originally written by User:Sikon for Wookiepedia * Rewritten by User:Quarenon for RuneScape Wiki * Updated by User:Eladkse for Casualty Wiki * Updated to handle comments and tabindexes by User:452 * Updated to handle wide-screen mode and slightly optimized by User:Pecoes */ /*jshint jquery:true, browser:true, es5:true, devel:true, camelcase:true, curly:false, undef:true, bitwise:true, eqeqeq:true, forin:true, immed:true, latedef:true, newcap:true, noarg:true, unused:true, regexp:true, strict:true, trailing:false*/ /*global mw, importArticle */ $(function {   'use strict';    var $textarea = $('#wpSummary');    if (!$textarea.length || document.getElementById('stdSummaries')) return;    var presets = (window.dev && window.dev.editSummaries) || {},        select = presets.select || 'Template:Stdsummaries';    $textarea.attr('tabindex', '3'); //set tabindex for summaries text area    $('#wpMinoredit').attr('tabindex', '4'); //set tabindex for minor edit checkbox    $('#wpSave').attr('tabindex', '5'); //set tabindex for publish button    var $summary = $('#wpSummaryEnhanced');    if (!$summary.length) $summary = $textarea;    if ('css' in presets) {        mw.util.addCSS(presets.css);    } else {        importArticle({ type: 'style', article: 'u:dev:MediaWiki:Standard_Edit_Summary.css' });   }    var $combo = $('<select id="stdSummaries" tabindex="2"> ')    .insertAfter($textarea)    .change(function { //var val = $summary.val; //$summary.val(val + (val.length ? '; ' : '') + $(this).val); $summary.val($(this).val); });   function flatten (options, indent) {        var flattened = [];        indent = indent || ;        for (var i = 0; i < options.length; i++) {            if ($.isArray(options[i])) {                flattened = flattened.concat(flatten(options[i], '-- '));            } else {                flattened.push(indent + options[i]);            }        }        return flattened;    }    function render (lines) {        var options = , selected = ' selected',            ignore = { ':': 1, '*': 1,  '<': 1 };        for (var i = 0; i < lines.length; i++, selected = '') {            if (!lines[i].length || ignore[lines[i][0]]) {                continue; // lines beginning with these characters: : * < are ignored            }            if (lines[i].substring(0, 3) === '-- ') {                var contents = mw.html.escape( lines[i].substring(3) );                options += '<option value="' + contents + '"' + selected + '> ' + contents + ' '; } else { options += '<option value="" disabled' + selected + '>' + mw.html.escape( lines[i] ) + ' '; }       }        $combo.append(options); }   if (typeof select === 'string') { $.get(mw.util.getUrl(select, {action: 'raw'})) .done(function (data) {           render(data.split(/\r\n|\n|\r/));        }); } else if (Array.isArray(select)) { render(flatten(select)); } });

/* Clock */ window.DisplayClockJS = '%X %x [%{Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday}w] (UTC)'; /* Last edit header */ window.lastEdited = { avatar: true, size: false, diff: true, comment: true, time: 'timeago', namespaces: { include: [], exclude: [] },   pages: [] };

/** * Ajax Page Rename * Allows the user to quickly rename a page without having to load Special:MovePage * https://community.wikia.com/wiki/User:Cörey */ (function($, mw) {   var config = mw.config.get([ 'wgPageName' ]),   $list = $('.page-header__contribution-buttons .wds-list');    if(!$list.find('#ca-move').exists || window.AjaxRenameLoaded) {        return;    }    window.AjaxRenameLoaded = true;    importArticle({ type: 'script', article: 'u:dev:MediaWiki:I18n-js/code.js' });   var token = mw.user.tokens.get('editToken'), i18n, api;    function init(res) {        i18n = res;        $list.append( $('<li>').append(               $('<a>', { href: '#', id: 'ajax-rename' })               .text(i18n.msg('button').plain)                .click(renamePage)            ) );   }    function renamePage {        i18n.useContentLang;        var defaultReason = i18n.msg('default-reason').plain;        i18n.useUserLang;        var newName = prompt(i18n.msg('target-prompt').plain, '');        if (newName === null) {            return;        }        var moveReason = prompt(i18n.msg('reason-prompt').plain, defaultReason);        if (moveReason === null) {            return;        }        api.post({ action: 'move', from: config.wgPageName, to: newName, movesubpages: '', movetalk: '', reason: moveReason, token: token }).done(function(d) { if (d.error) { alert(i18n.msg('error', d.error.code).plain); } else { alert(i18n.msg('success', config.wgPageName, newName).plain); location.reload(true); }       }).fail(function { alert(i18n.msg('error', i18n.msg('ajax-error').plain).plain); });   }    mw.loader.using('mediawiki.api').then(function { api = new mw.Api; mw.hook('dev.i18n').add(function (i18no) {           i18no.loadMessages('AjaxRename').done(init);        }); }); })(this.jQuery, this.mediaWiki);