User:Sophiedp/global.js

/* AdvancedOasisUI settings */ window.AdvancedOasisUI = { accountNavFollowedPages: true, accountNavWatchlist: true, lightbox: true };

/* Block links */ if (mw.config.get("wgUserGroups").indexOf('sysop') > -1) { $(window).load(function {       $('.tag-container').after('Block');    }); }

/* Alert if global.js loads in chat */ if ( wgCanonicalSpecialPageName == 'Chat' ) { alert('Loaded through global.js'); } /* EditCount popup */ (function($, mw) {   if (!$ || !mw || !$('.tally').length) return;    mw.util.addCSS('.editCount{z-index:100;position:fixed;}.ecrowcenter{text-align:center;}.ecrowright{text-align:right;}.TablePager,.TablePager td,.TablePager th{padding:0 0.15em 0 0.15em;}');    $(document).mousemove(function(e) { window.pos = {x: e.clientX, y: e.clientY, el: e.target}; });   var $tally = $('.tally');    $tally.hover(function { var html; var wait; $.get('/wiki/Special:EditCount/' + wgTitle, function(d) {           html = $(d).find('.TablePager').parent.html;            if (wait && ($(pos.el).is('.tally') || $(pos.el).closest('.tally').length)) {                $('').html(html).appendTo('body');            }        }); window.editCountTimeout = setTimeout(function {           if (!html) wait = true;            else if ($(pos.el).is('.tally') || $(pos.el).closest('.tally').length) {                $('').html(html).appendTo('body');            }        }, 700); }, function { setTimeout(function {           var $el = $(pos.el);            var $ec = $('.editCount');            if ($el.is('.editCount') || $el.closest('.editCount').length) {                $ec.hover($.noop, function { $ec.remove; });           } else {                $ec.remove;                clearTimeout(window.editCountTimeout);            }        }, 100); }); }) (window.jQuery, window.mediaWiki);

/* Cool stuff for RC */ (function {var original = document.title;if (typeof blinkInterval === 'undefined') {window.blinkInterval = 1000;}var timeout;window.blinkTitle = function(newMsg) {function step {document.title = (document.title == original) ? newMsg : original;timeout = setTimeout(step, blinkInterval);}cancelBlinkTitle(timeout);step;};window.cancelBlinkTitle = function {clearTimeout(timeout);document.title = original;};}); $(window).focus(function {   cancelBlinkTitle; }); $(function {    if ( wgPageName == 'User:Sophiedp/RC' && wgAction == 'view' ) {        var $doc = $(window);        var rcid = "RecentChangesMultiple-autorefresh-" + mw.config.get("wgPageName");        $doc.click(function(e) { if ($(e.target).is('a') || $(e.target).parents('a').length ) { $(e.target).parents('a').attr('target', '_blank'); $(e.target).attr('target', '_blank'); }       });        $doc.focus(function { if (window.stopResponsive) return; var $checkbox = $('.rcm-autoRefresh-checkbox'); if ($checkbox.length) { $checkbox.prop('checked', false); $checkbox[0].dispatchEvent(new Event('click')); }           localStorage.setItem(rcid, false); if (window.latestRCMNotification) { latestRCMNotification.close; }       });        $doc.blur(function { if (window.stopResponsive) return; var $checkbox = $('.rcm-autoRefresh-checkbox'); if ($checkbox.length) { $checkbox.prop('checked', true); $checkbox[0].dispatchEvent(new Event('click')); }           localStorage.setItem(rcid, true); });       Notification.requestPermission;        window.onbeforeunload = function(e) {            return 'Man you must be out of your mind!';        };        setInterval(function { if (window.throttleForRCM || !$('.rc-conntent > div').length || !$('.rc-conntent > div > table').length) return; if (!window.lastTableHTML) { window.lastTableHTML = $('.rc-conntent > div > table:first .mw-enhanced-rc:first').html; return; }           if ( window.lastTableHTML != $('.rc-conntent > div > table:first .mw-enhanced-rc:first').html ) { window.lastTableHTML = $('.rc-conntent > div > table:first .mw-enhanced-rc:first').html; if (!document.hasFocus) { blinkTitle('New edits!'); // Display desktop notification. window.latestRCMNotification = new Notification("New edits!"); }           }        }, 3000);    } });

/* More flexible AjaxUndo */ jQuery(document).ready(function($) {   "use strict";    function createUndoLink(diffUndoUrl) {        var $ajaxUndoLink = $('').text('AJAX Undo').attr('href', '#').click(function { var $ajaxUndoLinkob = $(this), undoIdRegex = /&undo=([^&]*)/, undoId = undoIdRegex.exec(diffUndoUrl)[1], editToken, etUrl = wgServer + wgScriptPath + '/api.php?action=query&prop=info|revisions&intoken=edit&titles=' + encodeURIComponent(wgPageName) + '&format=json', usrUnd = $('#mw-diff-ntitle2 .mw-userlink').html, smry = prompt('Undo summary', 'Undo revision ' + undoId + ' by ' + usrUnd + ' (talk)'); if (smry === null) return; else if (!smry) smry = 'Undo revision ' + undoId + ' by ' + usrUnd + ' (talk)'; $ajaxUndoLinkob.html(' '); $.getJSON(etUrl, function(data) {               editToken = data.query.pages[wgArticleId].edittoken;                $.ajax({ url: wgScriptPath + '/api.php?', data: 'action=edit&format=json&title=' + encodeURIComponent(wgPageName) + '&undo=' + encodeURIComponent(undoId) + '&bot=1&summary=' + encodeURIComponent(smry) + '&token=' + encodeURIComponent(editToken), dataType: 'json', type: 'POST', success: function(data) { if (data.edit && data.edit.result === 'Success') { $ajaxUndoLinkob.text('(undone)'); } else if (data.error && data.error.code === 'undofailure') { $ajaxUndoLinkob.text('(error)'); alert(data.error.info); } else { $ajaxUndoLinkob.text('(error)'); alert('Error: Unknown result from API.'); }                   },                    error: function { $ajaxUndoLinkob.text('(error)'); }               });            });        });        return $ajaxUndoLink;    }    if ($('.mw-history-undo > a').length && wgAction === 'history') {        $('.mw-history-undo > a').each(function { var diffUndoUrl = $(this).attr('href'), $ajaxUndoLink = createUndoLink(diffUndoUrl); $(this).replaceWith($ajaxUndoLink); });   } else if ($('table.diff').length && typeof $.getUrlVar('diff') !== 'undefined') {        var $diffUndoLink = $('table.diff').find('.diff-ntitle > #mw-diff-ntitle1 a:last'),            diffUndoUrl = $diffUndoLink.attr('href'),            $ajaxDiffUndoLink = createUndoLink(diffUndoUrl);        $diffUndoLink.replaceWith($ajaxDiffUndoLink);    } });

/* Redirect to base page if ends with '/' */ if (window.location.href.match("/$")) { window.location.href = window.location.href.slice(0, -1); }

//—————————————————————————————— ! ! ! ———————————————————————————————// /* Import scripts. NOTE: Place scripts configurations above this line */

/* Sine */ importScriptURI('https://gist.githubusercontent.com/LunarTwilight/542e36111f0ebf3d12b09196be6151af/raw/a7315bb58ab0d03b63078d0dac0ffc8cdaf82f91/sine.js');

/* ColoredColors */ importScriptURI('https://gist.githubusercontent.com/LunarTwilight/084c986abe21b81afbc9f42a83d7a23f/raw/9750ff951d3976920838d89c4c40deb4c591af01/ColoredColors.js');

/* Imports */ $(window).load(function {   importArticles({ type: "script", articles: [ 'u:dev:MediaWiki:ViewRemoved/code.js', 'u:dev:MediaWiki:Rollback/code.js', 'u:dev:MediaWiki:Wikimarks/code.js', 'u:dev:MediaWiki:WallGreetingButton/code.js', 'u:dev:MediaWiki:PurgeButton/code.js', 'u:dev:MediaWiki:NullEditButton/code.js', 'u:dev:MediaWiki:QQX/code.js', 'u:dev:MediaWiki:RevealAnonIP/usercode.js', 'u:dev:MediaWiki:AutoEditDropdown/code.js', 'u:dev:MediaWiki:PortableCSSPad/code.js' ]   }); });

/* Make DisplayClock and AdvancedOasisUI scripts not load on AT and SP */ if (wgCityId != "7553" && wgCityId != "95") { importScriptPage('MediaWiki:DisplayClock/code.js', 'dev'); importScriptPage('MediaWiki:AdvancedOasisUI/code.js', 'dev'); }