User:Dorumin/global.js

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

// Add quick logs mw.hook('QuickLogs.loaded').add(function(ql) {   ql.addLink('useravatar', { message: 'avatar log', by: ql.user }, 4);   ql.addLink('delete', { message: 'delete log', by: ql.user }, 7); });

// Kill infobox editor $('#ca-edit').each(function {   var $this = $(this);    $this.attr('href', $this.attr('href') + '&useeditor=source'); });

// 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, [itemprop="video"]').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';

// 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;

window.ViewRemovedAlways = true;

window.announcementsIgnore = { option: 'opt-out-all', exceptWikiIds: [] };

/****************** 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.2.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:AnnouncementsIgnore.js',        'u:dev:CodeSelectAll/code.js',        'u:dev:ContribsLink/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:ViewDeleted/code.js', 'u:dev:ViewRemoved/code.js', 'u:dev:WHAM/code.2.js', 'u:dev:WorkingMoreUsersCount.js' ] });