User:Eizen/global.js

/** * @file Unless otherwise stated, the snippets on this page were written by me. * Feel free to use/modify them as desired, provided proper attribution is * included. */

/** * Assorted window variables */ window.isBlogLinkLoaded = true; window.isPTPLoaded = true; window.SeeMoreActivityButtonLoaded = true; window.DiscordIntegratorLoaded = true; window.monoBookText = "Monobook"; window.oasisText = "Oasis"; window.mobileText = "Mercury"; window.ajaxPages = [ "Special:WikiActivity", "Special:RecentChanges", "Special:Log" ]; window.pageCreatorConfig = { avatar: false, useTimestamp: true }; window.lastEdited = { avatar: false, size: false, comment: false, namespaces: { include: [0, 4, 8, 10, 14], exclude: [1, 2, 3, 5, 6, 7, 9, 11, 12, 15, 110, 111, 828, 829, 1202] } };

/** * Forbid double loading of Contribs option via BlogLink and ContribsLink */ if (mw.config.get("wgCityId") === "1399015") { var $interval = setInterval(function {        if (window.isBlogLinkLoaded && jQuery("#bl-contributions").exists) {            clearInterval($interval);            jQuery("#bl-contributions").css("display", "none");        }    }, 200); }

/** * Replace various items in "Explore" dropdown menu with links to more useful * pages. */ function changeDropdownItems ($original, $newDataTracking, $newUrl, $text) { if (       jQuery.inArray(mw.config.get("skin"), ["oasis", "wikia"]) !== -1 &&        jQuery("a[data-tracking='" + $original + "']").exists &&        !jQuery("a[data-tracking='" + $newDataTracking + "']").exists    ) { mw.loader.using("mediawiki.util", function {            jQuery("a[data-tracking='" + $original + "']")                .attr("href", mw.util.getUrl($newUrl))                .attr("data-tracking", $newDataTracking)                .text($text);        }); } }

var $changedItemsArray = [ {       originalTracking: "explore-community", newTracking: "explore-upload", newUrl: "Special:Log/upload", text: "Upload Log" },   {        originalTracking: "explore-random", newTracking: "explore-changes", newUrl: "Special:RecentChanges", text: "Recent Changes" },   {        originalTracking: "explore-videos", newTracking: "explore-log", newUrl: "Special:Log", text: "Special Log" } ].forEach(function ($item) {   changeDropdownItems( $item.originalTracking, $item.newTracking, $item.newUrl, $item.text ); });

/** * Hide list items without actual ids or class names */ if (jQuery.inArray(mw.config.get("skin"), ["oasis", "wikia"]) !== -1) { [       "a[data-tracking='admindashboard/toolbar/admin']", "a[data-name='history']", "a[data-name='whatlinkshere']", ".tools-customize", ".global-shortcuts-help-entry-point", //"#ca-unwatch", "#ca-ve-edit" ].forEach(function ($item) {       jQuery($item).closest("li").remove;    }); }

/** * Bypass Special:InfoboxBuilder * Modified from code by User:Ursuul */ if (mw.config.get("wgCanonicalSpecialPageName") === "InfoboxBuilder") { var $pageName = "Template:" + mw.config.get("wgPageName").split("/")[1] + "?action=edit&useeditor=source"; window.location.href = mw.config.get("wgArticlePath").replace("$1", $pageName); }

/** * Rename Dev ContMod to Codeeditor */ if (mw.config.get("wgCityId") === "7931") { jQuery(".tag").each(function (index) {       if (jQuery(this).text === "Content Moderator") {            jQuery(this).text("Codeeditor");        }    }); }

/** * Expand collapsed sections in Recent Changes and WikiWatch */ if (   jQuery.inArray( mw.config.get("wgPageName"), ["Special:RecentChanges", "Eizen:WikiWatch"] ) !== -1 ) {   jQuery("Collapse") .appendTo(".toolbar .tools") .click(function {            jQuery(".mw-rc-openarrow").click;        }); }

/** * Disable 5 second delay used to send tracking event * @author OneTwoThreeFall  */ GlobalTriggers.bind("WikiaEditorReady", function (editor) {   if (editor.controls) {        editor.controls.editform.off("submit").on("submit", function  { editor.setState(3); });   } });

/** * Remove Discussions tally on own user page */ if (   mw.config.get("wgCityId") !== "1619339" &&    jQuery(".UserProfileMasthead .masthead-info h1").text === "Eizen" ) { jQuery(".discussion-details").remove; }

/** * Modified TabKeyInserter for mainspace .javascript pages */ if (   mw.config.get("wgAction") === "edit" &&    (/\.(?:javascript|css)$/i).test(mw.config.get("wgPageName")) ) { jQuery("#wpTextbox1").keydown(function (evt) {       if (evt.keyCode === 9) {            evt.preventDefault;

var $begin = this.selectionStart; var $end = this.selectionEnd;

jQuery(this).val(               jQuery(this).val.substring(0, $begin) + "\t" +                jQuery(this).val.substring($end)            );

this.selectionStart = $begin + 1; this.selectionEnd = $begin + 1; }   }); }

/** * Stripped down version of User:OneTwoThreeFall's GlobalChatJS */ if (window.ChatWidget && ChatWidget.onClickChatButton) { ChatWidget.onClickChatButton = function ($chatLink) { var $chatUrl = $chatLink && new mw.Uri($chatLink); var $chatWindow = window.open($chatUrl.toString, "wikiachat", "");

$chatWindow.addEventListener("DOMContentLoaded", function {            $chatWindow.importArticles({ type: "script", articles: [ "u:dev:ChatAwayButton/code.js", "u:dev:ChatBlockButton/code.3.js", "u:dev:ChatMessageWallCount/code.js", "u:dev:ChatUserPageButton.js", "u:dev:NewMessageCount.js", "u:dev:PrivateMessageAlert/code.js", //"u:eizen:User:Eizen/UnbindEnterKey.javascript" ]           });        }, false); }; }

/** * General purpose imports to all wikis */ importArticles({   type: "script",    articles: [        "u:dev:AjaxBatchDelete/code.2.js",        "u:dev:AjaxRC/code.js",        "u:dev:AjaxUndo/code.js",        "u:dev:CodeQuickLinks/code.js",        "u:dev:ConsistentModules/code.js",        "u:dev:DisableCode/code.js",        "u:dev:EditConflictAlert/code.js",        "u:dev:MassEdit/code.js",        "u:dev:NullEditButton/code.js",        "u:dev:PortableCSSPad/code.js",        "u:dev:QuickDiff/code.js",        "u:dev:RevealAnonIP/usercode.js",        "u:dev:Rollback/code.2.js",        "u:dev:SkinSwitchButton/code.js",        "u:dev:TabKeyInserter/code.js",        "u:dev:ToolbarLinks/code.js",        "u:dev:ViewRemoved/code.js",        "u:dev:WorkingMoreUsersCount.js",        "u:eizen:User:Eizen/AnonLookup.javascript",        //"u:eizen:User:Eizen/BotEdit.javascript",        "u:eizen:User:Eizen/ContribsLink.javascript",        "u:eizen:User:Eizen/CreateUserPage.javascript", "u:eizen:User:Eizen/InsertTemplate.javascript", //"u:eizen:User:Eizen/LetItSnow.javascript", "u:eizen:User:Eizen/PurgeEditTally.javascript", //"u:eizen:User:Eizen/RandomChristmasSong.javascript" ] });

/** * Ensures that TallyLink only loads once a tally refresh has occurred * via PurgeEditTally.js */ if (mw.config.get("wgNamespaceNumber") === 2) { mw.hook("refreshedMasthead").add(function {        importScriptPage("TallyLink/code.js", "dev");    }); } else { importScriptPage("TallyLink/code.js", "dev"); }

/** * Give option to hide rail if a JS/CSS pre section exists on the page */ if (   mw.config.get("wgNamespaceNumber") === 8 &&    (jQuery(".source-javascript").exists || jQuery(".source-css").exists) ) { importScriptPage("ToggleSideBar/code.js", "dev"); }

/** * User page-related scripts */ if (   jQuery("#UserProfileMasthead").exists &&    jQuery(".UserProfileMasthead .masthead-info h1").text !== "Eizen" &&    mw.config.get("wgSitename") !== "Eizen" ) { importArticles({       type: "script",        articles: [            "u:dev:UnhideUserMasthead/code.js",            "u:dev:UserAccountAge/beta.js"        ]    }); }

/** * Page-specific imports */ if (mw.config.get("wgCityId") === "1619339" && mw.config.get("wgArticleId") === 98) { window.customToolbarLinks = [ {           action: "link", address: "MediaWiki:Common.css?action=edit", title: "Common" }   ]; }

/** * Wiki-specific imports */ switch (mw.config.get("wgCityId")) { case "644": importArticles({       type: "script",        articles: [            "u:eizen:User:Eizen/LastEdited.javascript",            "u:dev:PageCreator/code2.js"        ]    }); break; case "177": window.customToolbarLinks = [ {           action: "link", address: "User:Eizen/global.js?action=edit", title: "Global JS" },       {            action: "link", address: "User:Eizen/global.css?action=edit", title: "Global CSS" },       {            action: "link", address: "Template:User:Eizen?action=edit", title: "Edit Template" },       {            action: "import", script: "EditBio/code.js", title: "EditBio" }   ];    break; }