User:RyaNayR/global.js

/*jshint multistr: true */ /******************************************************************************/ ///* ChatRefresh // *  By IAmAPersson ( http://community.wikia.com/wiki/User:IAmAPersson ) // * Original release date: January 20, 2014 // */ // //console.log('ChatRefresh: Init.'); //if (refreshTime === 0) { //   var refreshTime = 300000; //   alert('ChatRefresh: Setting refreshTime = 300000'); //} // //if (wgCanonicalSpecialPageName === 'Chat') { //   console.log('ChatRefresh: Chat namespace detected.'); //   setInterval(function { //            alert('ChatRefresh: Attempting to clear chat window.'); //            active.clearWindow; //        }, refreshTime //    ); //}

/********************/

var toolbarCSS = mw.util.addCSS('                                                                  \    .WikiaBarWrapper .toolbar { width: 111% }                                                       \    .WikiaBarWrapper .toolbar .tools li a {                                                         \        color: #0f5;                                                                                \        font-weight: 700                                                                            \    }                                                                                               \    .WikiaBarWrapper .toolbar .tools .arrow-icon {                                                  \        border-color: transparent transparent lime;                                                 \    }                                                                                               \ .WikiaBarWrapper .tools-menu {                                                                 \ background   : linear-gradient(#000064, #6496ff, #000064) repeat scroll 0 0 transparent;   \ border-radius : 8px;                                                                       \ border       : 2px solid silver;                                                           \ min-width    : 90px;                                                                       \ text-align   : center;                                                                     \ }                                                                                              \    .WikiaBarWrapper .tools-menu > li > a { border-top: 1px solid #323232 }                         \ .WikiaBarWrapper {                                                                             \ background: linear-gradient(to bottom, #3264af 25%, #00327d 50%, #00194b 75%);             \ }                                                                                              \    .WikiaBarWrapper a { transition: color 500ms ease-in-out !important }                           '), tpwCSS = mw.util.addCSS('                                                                           \ .skin-oasis > .global-notification,                                                            \ .WikiaHeader .page-width-container,                                                        \ .WikiaPage                     { max-width:90%; width:90% }                            \ .WikiaArticle .diff-article-content,                                                           \ .diff-article-content              { margin-right: 0; width: 90% }                         \ .WikiaMainContent                      { width: 100% }                                         '), modalCSS = mw.util.addCSS('                                                                         \ .modal                                 { width: calc(100% - 750px) !important }                '), editPreviewCSS = mw.util.addCSS('                                                                   \ .ArticlePreviewInner                   { width: 90% !important }                               \ #EditPageDialog {                                                                              \ left : 41% !important;                                                                     \ width : 66% !important;                                                                    \ }                                                                                              '), buttonFixCSS = mw.util.addCSS('                                                                     \ .EditPage .module_page_controls .wikia-menu-button { padding-bottom: 2px }                     \ #wpSave { height: 20px }                                                                       ');

toolbarCSS.disabled    = false; modalCSS.disabled      = false; tpwCSS.disabled        = true; editPreviewCSS.disabled = true; buttonFixCSS.disabled  = true;

$(window).load(function {   if (tpwCSS.disabled === false) {        togglePageWidth;    } });

function togglePageWidth { if ($('#code')) $('#WikiaMainContent').removeAttr('style'); $('.WikiaRail').remove tpwCSS.disabled = !tpwCSS.disabled; } function toggleModalWidth { modalCSS.disabled = !modalCSS.disabled; } function toggleCustomToolbar { toolbarCSS.disabled = !toolbarCSS.disabled; } function togglePreviewWidth { editPreviewCSS.disabled = !editPreviewCSS.disabled; } function toggleButtonFix { buttonFixCSS.disabled = !buttonFixCSS.disabled; }

// Add toolbar buttons $('#WikiaBarWrapper .toolbar > .tools').append('Toggle Page Width'); $('#WikiaBarWrapper .toolbar > .tools').append('Toggle Custom Toolbar '); $('#WikiaBarWrapper .toolbar > .tools').append('Toggle Button Fix');

// Create ToggleModalWidth button $(document).on('DOMNodeInserted', function (e) {   if (e.target.id === 'wikiDiff') {        $('.modal > header > h3').append('Toggle Width ');    } });

// Create TogglePreviewWidth button $(document).on('DOMNodeInserted', function (e) {   if (e.target.id === '#EditPageDialog h1') {        $('#EditPageDialog h1').append('Toggle Width ');    } });

// Keyboard shortcuts: $("body").bind("keydown", keyDown);

function keyDown (e) { // Alt + P:   if ((e.altKey) && (e.keyCode === 80)) { togglePageWidth; }   // Alt + Period: if ((e.altKey) && (e.keyCode === 190)) { togglePreviewWidth; }   // Alt + M:    if ((e.altKey) && (e.keyCode === 77)) { toggleModalWidth; }   // Alt + M:    if ((e.altKey) && (e.keyCode === 191)) { toggleButtonFix; } }

/*** toggleAds ***/ var adsVisible = true; mw.util.addCSS('#ToggleAds-checkbox{margin:0 4px 0 0;position:relative;top:2px}');

$('.toolbar .tools').append('Hide ads</a> </li>'); $('#ToggleAds-checkbox').prop('checked', false); $('#ToggleAds-checkbox').change( toggleAds );

function hideAds { $('.home-top-right-ads, .WikiaTopAds').css('display', 'none'); adsVisible = false; } function showAds { $('.home-top-right-ads, .WikiaTopAds').css('display', 'block'); adsVisible = true; } function toggleAds { if ( /*$('#ToggleAds-checkbox').prop('checked') === true || */adsVisible === true) { hideAds; $('#ToggleAds-checkbox').prop('checked', true); } else { showAds; $('#ToggleAds-checkbox').prop('checked', false); } }

/******* Misc ********/ //$('.topNav').attr('display', 'none'); /*$('ul.tools > li:nth-child(1) > a:nth-child(1)').remove; $('ul.tools > li:nth-child(1)').remove;*/

/********************/ window.DisplayClockJS = { hoverText: '', interval: 200, monofonts: 'Consolas, monospace', location: 'global' };

mw.user.options.set({   'nocache'        : 1,    'norollbackdiff' : 1, });

window.AdvancedOasisUI = { accountNavFollowedPages : true, accountNavWatchlist    : true, categoryRedlink        : true, RCHeader               : true, DefaultSourceMode      : true, lightbox               : true, randomPageLimitedTo    : '', activity2RC            : false, userLang               : true, };

EditIntroButtonText = 'intro';

//. . . Importation. . .\\ // //if (headerLinks === undefined) { //   importArticles({ //        type: 'script', articles: ['u:dev:HeaderLinks/code.js'] //    }); //   console.log('HeaderLinks loaded! (Personal JS)'); //} else { //   console.log('HeaderLinks loaded! (Wiki JS)'); //}

//TODO: Auto-reduncancy-check

window.unsafeScriptsConfig = { 'dropdown': true };

importArticles({   type: 'script',    articles: [            //'User:RyaNayR/CustomToolbarToggle.js',            //'u:dev:Code/code.js'                  ,            //'User:RyaNayR/Code/code.js'           ,        'u:dev:MediaWiki:AutoEditDropdown/code.js'  ,        'u:dev:MediaWiki:QQX/code.js'               ,        'u:dev:MediaWiki:PortableCSSPad/code.js'    ,        'u:dev:MediaWiki:View_Source/code.js'       ,  //TODO: Check if needed still        'u:dev:MediaWiki:UnsafeScripts/personal.js' ,  //TODO: Check if needed still        //'u:dev:MediaWiki:FixMultipleUpload/code.js' ,  //TODO: Check if needed still        'u:dev:MediaWiki:AdvancedOasisUI/code.js'   ,        'u:dev:MediaWiki:EditIntroButton/code.js'   ,        'u:dev:MediaWiki:HeaderLinks/code.js'       ,        'u:dev:MediaWiki:SearchSuggest/code.js'     ,        'u:dev:MediaWiki:AjaxUndo/code.js'        //'u:dev:WhatLinksHere/code.js' //endl //'u:dev:Sine/code.js'                 , //'u:dev:MiniComplete/code.js'         , //'u:dev:QuickTools/advanced.js'       , //'u:dev:ListFiles/code.js'            , //'u:dev:HideRail/code.js'             , //'u:dev:DisplayClock/code.js'         , //'u:dev:AjaxBatchDelete/code.js'      , ] });

/******************************************************************************/

// Custom toolbar links: function addToolbarLinks { $('.tools-menu > li:nth-child(1)').prepend('\       global.css</a>\        global.js</a>\        CtCD Wikia.js</a>\        CtCD CSS</a>'); return 0; } window.onload = function { if ( addToolbarLinks === 0 ) { console.log("Your custom toolbar links have been added!"); } else { console.log("Failed to add custom toolbar links..."); } };

/* window.onload = function { $('.tools-menu > li:nth-child(1)').prepend('global.css</a>global.js</a>CtCD Wikia.js</a>CtCD CSS</a>'); };

var fixUserMenu = (function ($) {   if ($('.wds-global-navigation__user-menu .wds-dropdown__content').addClass('wds-is-not-scrollable')) return true;    else return false; })(jQuery);

console.log('Force GlobalNav UserMenu non-scrollable: ' + fixUserMenu);

$('.wds-avatar img').text(' <img src="https://vignette.wikia.nocookie.net/de62f384-27aa-4579-a2e5-cefa238559a9/scale-to-width-down/50" alt="RyaNayR" title="RyaNayR" class="wds-avatar__image"></a> ');

$(document).ready(function { $('.note').replaceWith('' + $('.note').text + '</a>'); }); $('[data-toggle="tooltip"]').tooltip; $('.note').tooltip({trigger: "click focus"});