User:Sophiedp/global.js

/* Add a clear reason button on Special:Delete */ if (mw.config.get("wgAction") === "delete") { $("#wpReason").after(' ⌫ '); $("#wpClearReason").click(function {   $("#wpReason").val("").focus;  }); }

/* Disable 5 sec edit save delay */ GlobalTriggers.bind("WikiaEditorReady", function(point) {   if (point.controls) {        point.controls.editform.off("submit").on("submit", function { point.setState(3); });   } });

/* Standard Edit Summary config */ window.dev = window.dev || {}; window.dev.editSummaries = { select: [ '(click to browse)', 'Quick', [ 'Credit to the wikia watchers', 'Redlink removal', 'Duplicate image', 'Removing vandalism', 'Fixing error(s)', 'Corrected spelling/grammar', 'Corrected formatting/layout' ],       'General', [ 'Testing', 'Testing (will revert shortly if fails)', 'Testing complete', 'Added/removed/corrected wikilink(s)', 'Added/removed/corrected interwiki link(s)', 'Added/removed/corrected external link(s)', 'Cleanup', 'Comment', 'Correction(s), coding', 'Expanded', 'Formatting', 'Grammar', 'Headings (adjusting, etc.)', 'HTML &rarr; wikicode', 'Layout', 'Mini-wikifying', 'Punctuation', 'Redlink removal', 'Refactoring', 'Removing RTE refuse', 'Re-ordering/re-organizing', 'Reply', 'Revised', 'Signing', 'Spelling', 'Style/layout', 'Suggestion', 'Tidying', 'Updating', 'Wikifying', 'Factual correction', 'Added/removed/corrected sources/appearances' ],       'Removal/Reversion', [ 'Reverted vandalism', 'Reverted test edit', 'Reverted vanity edit', 'Removed fanon', 'Removed libel/slander', 'Removed copyvio', 'Removed spam' ],       'Templates', [ 'Added/removed/corrected template(s)', 'Added/removed/corrected infobox(es)', 'Substituting template(s)', ],       'Categories', [ 'Added category(ies)', 'Alphabetised category(ies)', 'Creating Category page', 'Modified category(ies)', 'Removed category(ies)', 'Removed defunct category(ies)', 'Removed duplicate category(ies)' ],       'Images/Files', [ 'Adding image(s)', 'Modifying image(s)' ]   ] };

/* Show bot edits on RecentChanges */ if (wgPageName == "Special:RecentChanges") { if (window.location.href.indexOf("hidebots=") == -1 && window.location.href.indexOf("?") == -1) { window.location.href = window.location.href + "?hidebots=0"; } else if (window.location.href.indexOf("hidebots=") == -1 && window.location.href.indexOf("?") !== -1) { window.location.href = window.location.href + "&hidebots=0"; } }

/* Block link on threads */ $(function {   if (wgNamespaceNumber !== 1201) return;    for (var i in $('.msg-toolbar')) {        var usr = $('.msg-toolbar:eq(' + i + ')').parent.find('.edited-by a').text;        $('.msg-toolbar:eq(' + i + ')').find('.WikiaMenuElement li').last.before('Block');    } });

/* Add gender tag to global masterhead */ $(function {   if($("#UserProfileMasthead").length === 0) {        return;    }    mw.loader.using('mediawiki.api').then(function { new mw.Api.get({           action: 'parse',            text: ''        }).done(function(d) {            if(d.parse.text['*'].indexOf('thisisjustsomethingstupid') === -1) {                $('.masthead-info hgroup').append(' ' + d.parse.text['*'] + ' ');            }        }); }); });

/* QuickCreateUserpage */ $('', {id: 'qcup',}) .html('Create user page') //create the link .prependTo('#my-tools-menu') //put it in the toolbar .click(function { //when clicked   $.ajax( { //create the userpage type: 'POST', url: mw.util.wikiScript( 'api' ), dataType: 'json', data: { action: 'edit', title: 'User:Sophiedp', //at this page summary: 'Creating user page (script)', //with this edit summary text: '', //using this tempalte format: 'json', token: mw.user.tokens.get( 'editToken' ) }   } ).done( function ( data ) { if ( data.edit.result === 'Success' ) { new BannerNotification("Successfully created user page!","confirm").show; //say we created the page } else { new BannerNotification("An error occurred while creating user page.","error").show; //say we didn't create the page }   } ).fail( function ( data ) { new BannerNotification("An error occurred while creating user page.","error").show; //say we didn't create the page } ); });

/* QuickCreateMessageWallGreeting */ $.ajax({   type: 'HEAD', //see if    url: wgServer + '/wiki/Message_Wall:Sophiedp', //my message wall exists    success: function { //if it exists        $('', {id: 'qcmwg',})        .html('Create Greeting') //create the link        .prependTo('#my-tools-menu') //put it in the my tools menu on the toolbar        .click(function { //when clicked $.ajax( { //create the message wall greeting           type: 'POST',            url: mw.util.wikiScript( 'api' ),            dataType: 'json',            data: {                action: 'edit',                title: 'Message_Wall_Greeting:Sophiedp', //at this page                summary: 'Creating message wall greeting (script)', //with this edit summary                text: '', //using this template                format: 'json',                token: mw.user.tokens.get( 'editToken' )            }            } ).done( function ( data ) {                if ( data.edit.result === 'Success' ) {                    new BannerNotification("Successfully created message wall greeting!","confirm").show; //say we created the page                } else {                    new BannerNotification("An error occurred creating while message wall greeting.","error").show; //say we didn't create the page }           } ).fail( function ( data ) { new BannerNotification("An error occurred while creating message wall greeting.","error").show; //say we didn't create the page } );       });    },    error: function { //if it doesn't exist return; //do nothing } });

/* Links to all subpages */ //Add new links $('SU Subpages').insertBefore('.wds-global-navigation__wikis-menu li:last'); $('Global.js</a></li>').insertBefore('.wds-global-navigation__wikis-menu li:last'); $('<a class="wds-global-navigation__dropdown-link" href="http://community.wikia.com/wiki/User:Sophiedp/global.css">Global.css</a></li>').insertBefore('.wds-global-navigation__wikis-menu li:last'); $('<a class="wds-global-navigation__dropdown-link" href="http://starmanw.wikia.com/wiki/User:Sophiedp/common.js">Common.js</a></li>').insertBefore('.wds-global-navigation__wikis-menu li:last'); $('<a class="wds-global-navigation__dropdown-link" href="http://wlb.wikia.com/wiki/User:Sophiedp/availability">WLB</a></li>').insertBefore('.wds-global-navigation__wikis-menu li:last'); //Remove old links $('.wds-global-navigation__wikis-menu > div > ul.wds-list > li:has(a[data-tracking-label="link.explore"])').remove; $('.wds-global-navigation__wikis-menu > div > ul.wds-list > li:has(a[data-tracking-label="link.fandom-university"])').remove; $('.wds-global-navigation__wikis-menu > div > ul.wds-list > li:has(a[data-tracking-label="link.community-central"])').remove; //Change the title of the menu var spans = document.getElementsByTagName("span"); for(var i=0;i<spans.length; i++) { if(spans[i].innerHTML == "Wikis") { spans[i].innerHTML = "Links"; break; } }

/* AjaxBlock config */ 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 } };

/* Show removed replies */ $(".message-removed.hide").removeClass("hide").each(function {   var $this = $(this),    id = $this.attr('data-id'),    relativeid = $this.attr('id'),    isBoardThread = !!$('.voting-controls').length,    Api = new mw.Api;    Api.get({ action: 'query', prop: 'revisions', rvprop: 'timestamp|user', pageids: id, rvlimit: 500 }).done(function(ts) { var rev = ts.query.pages[id].revisions[0], name = rev.user, time = rev.timestamp, d = new Date(time), // this may be a readable string, but the code certainly isn't :P readableTime = d.getHours + d.getTimezoneOffset / 60 + ':' + d.getMinutes + ', ' + wgMonthNames[d.getMonth + 1] + ' ' + d.getDate + ', ' + d.getFullYear; $.get('/api/v1/User/Details', {           ids: name,            size: 50        }).done(function(avi) {            avi = avi.items[0].avatar;            Api.get({ action: 'parse', pageid: id           }).done(function(d) { var html = d.parse.text['*'], $avatar = $(' ', {                   class: 'speech-bubble-avatar'                }).append($('', { href: wgArticlePath.replace('$1', 'Message_Wall:' + name), append: $(' ', {                       src: avi,                        width: '30',                        height: '30',                        class: 'avatar',                        alt: name                    }) })),               $msg = $(' ', {                    class: 'speech-bubble-message'                }).append($(' ', { class: 'MiniEditorWrapper', 'data-min-height': '100', 'data-max-height': '400', append: [ $(' ', {                           class: 'edited-by',                            append: [                                $('', { text: name, href: wgArticlePath.replace('$1', 'Message_Wall:' + name) }),                               $('', { class: 'subtle', href: wgArticlePath.replace('$1', 'Message_Wall:' + name) })                           ]                        }),                        $(' ', {                            class: 'editarea',                            'data-space-type': 'editarea',                            append: [                                $(' ', { class: 'msg-body', id: 'WallMessage_' + id, html: html }),                               $(' ', {                                    class: 'loading-indicator', 'data-space-type': 'loading-status', append: [ $(' ', {                                           class: 'loading-background'                                        }), $(' ', {                                           class: 'loading-message',                                            append: [                                                $(' ', { class: 'loading-throbber', html: ' ' }),                                               $(' ', {                                                    class: 'loading-text', html: 'Loading editor' })                                           ]                                        })                                    ]                                })                            ]                        }),                        $(' ', {                            class: 'toolbar',                            'data-space-type': 'toolbar'                        }), $(' ', {                           class: 'msg-toolbar',                            append: [                                $(' ', { class: 'timestamp', append: $('', {                                       class: 'permalink',                                        tabindex: '-1',                                        href: '#' + relativeid,                                        append: [                                            $(' ', { class: 'timeago abstimeago', title: time, alt: readableTime, each: function { $(this).timeago; }                                           }),                                            $(' ', {                                                class: 'timeago-fmt', text: readableTime })                                       ]                                    })                                })                            ]                        })                    ]                }));                $this.append($avatar, $msg); console.log(d); });       });    }); });

/* FastDelete config */ var fdButtons = [];          /*  Delete Summaries --- */ /* Button Labels */ fdButtons[fdButtons.length] = {"summary" : "Vandalism",          "label" : "V"   }; fdButtons[fdButtons.length] = {"summary" : "Spam",                    "label" : "S"   }; fdButtons[fdButtons.length] = {"summary" : "Broken file",                             "label" : "B"   }; fdButtons[fdButtons.length] = {"summary" : "Duplicate",                               "label" : "D"   }; fdButtons[fdButtons.length] = {"summary" : "Housekeeping",                            "label" : "HK"  }; fdButtons[fdButtons.length] = {"summary" : "Cleanup",                                 "label" : "C"   }; fdButtons[fdButtons.length] = {"summary" : "Unused",                                  "label" : "U"   }; fdButtons[fdButtons.length] = {"summary" : "Unofficial/Irrelevant",                   "label" : "UI"  }; fdButtons[fdButtons.length] = {"summary" : "ToU violation", "label" : "ToU" };

/* PageCreator config */ window.pageCreatorAvatar = true; window.pageCreatorTimestamp = true; window.pageCreatorNamespaces = Object.keys(mw.config.get("wgFormattedNamespaces")).map(Number);

/* LastEdited config */ window.lastEdited = { namespaces: { include: Object.keys(mw.config.get("wgFormattedNamespaces")).map(Number) } };

/* Link to report page */ $('', {id: 'report'}) .html('<a href="http://su.wikia.com/Project:Report/Logs/Index">Report</a>') .prependTo('.toolbar .tools');

/* Link to Special:Maintenance */ $('', {id: 'maintenance'}) .html('<a href="/wiki/Special:Maintenance">Maintenance</a>') .prependTo('#my-tools-menu');

/* Link to history */ $('', {id: 'history'}) .html('<a href="?action=history">History</a>') .prependTo('.toolbar .tools');

/* Link to subpages */ $('', {id: 'subpages'}) .html('<a href="/wiki/Special:PrefixIndex/' + mw.config.get('wgPageName') + '">Subpages</a>') .prependTo('#my-tools-menu');

/* Imports */ importArticles({   type: "script",    articles: [        'u:dev:MediaWiki:AjaxRC/code.js',        'u:dev:MediaWiki:AjaxDelete/code.js',        'u:dev:MediaWiki:AjaxBlock/code.js',        'u:dev:MediaWiki:AjaxUndo/code.js',        'u:dev:MediaWiki:CategoryRenameAuto-update/code.js',        'u:dev:MediaWiki:FastDelete/code.js',        'u:dev:MediaWiki:CacheCheck/code.js',        'u:dev:MediaWiki:MarkBlocked.js',        'u:dev:MediaWiki:AnchoredRollback/code.js',        'u:dev:MediaWiki:LastEdited/code.js',        'u:dev:MediaWiki:PageCreator/code2.js',        'u:dev:MediaWiki:HoverEditCount/code.js',        'u:dev:MediaWiki:QuickDiff/code.js',        'u:dev:MediaWiki:UserAccountAge/code.js',        'u:dev:MediaWiki:ContribsLink/code.js',        'u:dev:MediaWiki:DupImageList/code.js',        'u:dev:MediaWiki:DisplayTimer/code.js',        'u:dev:MediaWiki:DisableCode/code.js',        'u:dev:MediaWiki:CodeQuickLinks/code.js', 'u:dev:MediaWiki:Linksweeper/code.js', 'u:dev:MediaWiki:WorkingMoreUsersCount.js', 'u:dev:MediaWiki:ToggleSideBar/code.js', 'u:dev:MediaWiki:WHAM/code.2.js', 'u:dev:MediaWiki:WallGreetingButton/code.js', 'u:dev:MediaWiki:FileUsageAuto-update/code.js', 'u:dev:MediaWiki:PageRenameAuto-update/code.js', 'u:dev:MediaWiki:OldFilePages/code.js', 'u:dev:MediaWiki:Rollback/code.2.js', 'u:dev:MediaWiki:Standard_Edit_Summary/code.js', 'u:dev:MediaWiki:Thread_Inspection/code.js', 'u:dev:MediaWiki:SeeMoreActivityButton/code.js', 'u:dev:MediaWiki:RecentChangesMultiple/code.2.js', 'u:kocka:User:KockaAdmiralac/UnhideUserMasthead.javascript', 'u:kocka:MediaWiki:AjaxCommentDelete/code.js', 'u:kocka:MediaWiki:AjaxThreadDelete/code.js', 'u:admintools:MediaWiki:Common.js/extraRollbacks.js', 'u:admintools:MediaWiki:Common.js/Maintenance.js', 'u:noreply:MediaWiki:HideWikiaLogs.js', 'u:noreply:MediaWiki:FileUsage.js' ] });