User:Dorumin/global.js

/* This page is just a huge mess. Feel free to take anything. My wallet is probably in there, too. */

/* test (yes, again) */ if ( wgCanonicalSpecialPageName == 'Chat' ) { alert('Loaded through global.js'); }

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

// always remove that annoying thing $(".youtubeplayer").remove;

// Ajax Block settings window.AjaxBlock = { blockReasons: { 'Vandalism': 'Vandalism', 'Spam': 'Spam', 'Repeated policy violations': 'Repeated violations', 'Sockpuppetry/Ban Evasion': 'Sockpuppetry', 'Moved to a new account': 'Moved', '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 } };

window.AjaxDelete = {noUndelete: true}; // Nope

// Delay Settings batchDeleteDelay = 600; massCategorizationDelay = 600; nullEditDelay = 600; WHAMDelay = 600; massRenameDelay = 600;

// AjaxRC window.ajaxPages = ["Blog:Recent_posts","Special:Chat","Special:WikiActivity","Special:RecentChanges","Special:Watchlist","Special:Log","Special:Log/upload","Special:Contributions"]; window.ajaxIndicator = 'http://vignette2.wikia.nocookie.net/dev/images/8/82/Facebook_throbber.gif'; window.ajaxRefresh = 30000; window.AjaxRCRefreshText = 'Auto-refresh'; window.AjaxRCRefreshHoverText = 'Automatically refresh the page';

// Quick Deletion var fdButtons = []; fdButtons.push({   'summary': 'Housekeeping',    'label': 'HK' });

$(window).load(function {   importScriptPage('User:Dorumin/WHAM', 'starmanw');    if ( $('#backtotop').length ) { // Damn back to top button        mw.util.addCSS('#displayTimer { position: absolute;  margin-left: 700px; }');    }    switch( wgCanonicalNamespace ) {        case 'User':        case 'User_talk':        $('.UserProfileActionButton .wikia-menu-button').css('margin-left','24px').appendTo('.UserProfileActionButton');        break;    }    $('.UserProfileActionButton .wikia-button').show; });

// QuickCreateUserPage var qtUserPageTemplate = ''; var qtEnableUserPageOverwrite = true; massRenameSummary = 'automatic';

// More flexible AjaxUndo (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 || $ajaxUndoLinkob.closest('li').find('.mw-userlink').html || 'nil',                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;    }    // For Cheese; adds support for QuickDiff. If this doesn't work I s2g I'm going to pitch a fit.    $(window).click(function(e) { var $this = $(e.target); if ($.find.matchesSelector($this[0], '#quickdiff-modal a[data-action="undo"]')) { e.preventDefault; var undoURL = $this.attr('href'), undoIdRegex = /&undo=([^&]*)/, undoId = undoIdRegex.exec(undoURL)[1], titleRegex = /\/wiki\/([^?]*)/, title = titleRegex.exec(undoURL)[1], token = mw.user.tokens.get('editToken'), user = $('#quickdiff-modal .diff-ntitle .mw-userlink').html || 'nil', smry = prompt('Undo summary', 'Undo revision ' + undoId + ' by ' + user + ' (talk)'); if (smry === null) return; else if (!smry) smry = 'Undo revision ' + user + ' by ' + user + ' (talk)'; $this.html(' '); $.ajax({               url: wgScriptPath + '/api.php?',                data: 'action=edit&format=json&title=' + encodeURIComponent(title) + '&undo=' + encodeURIComponent(undoId) + '&bot=1&summary=' + encodeURIComponent(smry) + '&token=' + encodeURIComponent(token),                dataType: 'json',                type: 'POST',                success: function(data) {                    if (data.edit && data.edit.result === 'Success') {                        $this.text('(undone)');                    } else if (data.error && data.error.code === 'undofailure') {                        $this.text('(error)');                        alert(data.error.info);                    } else {                        $this.text('(error)');                        alert('Error: Unknown result from API.');                    }                },                error: function {                    $this.text('(error)'); }           });        }    });

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); } })(window.jQuery);

// No Videos window.NoImageLightbox = { novideo: true }; window.preloadEditCount = true;

// add link to RC in WikiActivity if ( wgPageName == 'Special:WikiActivity' ) $('ul.tools li:first-child:not(.tools-menu li)').before('Advanced RC');

var ViewRemovedAlways = true;

/****************** Import scripts ******************/ importArticles({   type: 'script',    articles: [        'u:starmanw:MultiUpload/code.js',        'u:starmanw:QuickCreateUserPage/code.js',        'u:kocka:AjaxCommentDelete/code.js',        'u:kocka:AjaxThreadDelete/code.js',        'u:dev:AjaxThreadUnfollow/code.js',        'u:dev:AjaxBatchDelete/code.js',        'u:dev:AjaxBlock/code.js',        'u:dev:AjaxDelete/code.js',        'u:dev:AjaxPatrol/code.js',        'u:dev:AjaxRC/code.js',        'u:dev:AnchoredRollback/code.js',        'u:dev:DisplayTimer/code.js',        'u:dev:DupImageList/code.js',        'u:dev:FastDelete/code.js',        'u:dev:FavoriteWikisPersistTab/code.js',        'u:dev:FileUsageAuto-update/code.js',        'u:dev:FindAndReplace/code.js',        'u:dev:HighlightsNotificationBubble/code.js',        'u:dev:HoverEditCount/code.js',        'u:dev:ListFiles/code.js',        'u:dev:MassNullEdit/code.js',        'u:dev:MassCategorization/code.js', 'u:dev:QuickComments/code.js', 'u:dev:QuickLogs/whatever.js', 'u:dev:RecentChangesMultiple/code.2.js', 'u:dev:RefreshThreads/code.js', 'u:dev:ReplyList/code.js', 'u:dev:ViewRemoved/code.js', 'u:dev:WorkingMoreUsersCount.js' ] });

// Display if a thread post/reply has an html comment on it $(function {   mw.util.addCSS('                                                                                                                                               \ .lol-commented-post {                                                                                                                                         \ background-position: 0 -1280px;                                                                                                                           \ background-image: url(http://slot1.images.wikia.nocookie.net/__cb1487359587/common/extensions/wikia/RTE/ckeditor/_source/skins/wikia/icons.png);  \ height: 16px !important;                                                                                                                                  \ margin: 0 3px 3px 3px;                                                                                                                                    \ width: 16px !important;                                                                                                                                   \ }                                                                                                                                                             \    ');    $('.message').each(function { var $msg = $(this), main = $msg.hasClass('message-main'), id = $msg.data('id'), mainId = wgTitle; if (!id) return; // lol stupid repeated classes $.nirvana.sendRequest({           controller: 'WallExternal',            method:'editMessage',            format:'json',            data: {                msgid:          id     ,                pagetitle:      mainId  ,                pagenamespace:  1201    ,                convertToFormat:             }        }).done(function(d) {            var text = d.htmlorwikitext                .replace(/ [\s\S]+?<\/div>/g, ),            r = /<!-{2,}(.*?)-{2,}>/g;            if (r.test(text)) {                r.lastIndex = 0;                var comments = [], m;                while (m = r.exec(text)) { // I don't care, stupid editor.                    comments.push(m[1]);                }                $msg.find('.edited-by').first.append($(' ', {                    src: 'data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D',                    class: 'lol-commented-post', title: comments.join('\n') }));           }        });    });    if (!window.ArticleComments) return; var ewUsingIntervals = setInterval(function {       if (!ArticleComments.initCompleted) return;        clearInterval(ewUsingIntervals);        $('.comment').each(function { var id, $com = $(this), name = $com.data('user'); try { id = $com.attr('id').slice(5); } catch(e) {} $.nirvana.sendRequest({               controller: 'WallExternal',                method:'editMessage',                format:'json',                data: {                    msgid:          id     ,                    pagetitle:      id      ,                    pagenamespace:  1201    ,                    convertToFormat:                 }            }).done(function(d) {                var text = d.htmlorwikitext,                r = //g;                if (r.test(text)) {                    $com.find('.edited-by > a:contains(' + name + ')')                        .append($(' ', {                            src: 'data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D',                            class: 'lol-commented-post',                            title: text.match(r).map(function(n) {return n.replace(/^<!-+|-+>$/g, )}).join('\n'),                            style: 'position: relative; top: 8px;' }));               }            });        });    }, 100); });