User:TheWWRNerdGuy/global.js

// Go Ctrl+F (importArticles) to get actual explanations of the extensions rather than what I've changed. This stuff needs to be first because of load priorities and they won't work if after the imports.

window.AjaxUndoPrompt = true; /*SVsrn (AjaxUndo) The main reason I would use undo over Rollback is to give a reason. Doing this means I have to write a reason each time I'm using AjaxUndo.*/

window.toDoList = { page: 'User:TheWWRNerdGuy' }; /*1Vzz1 (ToDoList) Means that when I press to do, I get the straight source code of my profile. Much more useful than intended and I absolutely love it.*/

window.BotManagement = { notif: false, add: ':)',   remove: 'Okay done', }; /*sLgrH (BotManagement) Means I don't get notified by use of this script, and these are my respective summaries for adding and removing the right*/

window.massRenameSummary = ''

$.when($.ready, mw.loader.using(["mediawiki.api", "mediawiki.jqueryMsg"])).then(function{	return new mw.Api.loadMessagesIfMissing(["global-navigation-search-placeholder-inactive", "global-navigation-search-placeholder-in-wiki", "recentchanges","mediastatistics-header-video", "images"]); }).then(function{

//prevent double loading if( $(document.body).hasClass("oasis-is-revived") ) { return; }

var oasisRevivedClass = $(document.body).addClass("oasis-is-revived"); });

window.dev = $.extend(true, window.dev, {   i18n: {        overrides: {            Rollback: {                'summary': '$1',                'summaryShort': 'k'            }        }    } });

/** * UserAccountAge/code2.js * @file Appends user tag to masthead with time since account's creation * @author Eizen  * @license CC-BY-SA 3.0 * @external "mediawiki.api" * @external "mediawiki.util" */

/* jshint -W030, undef: true, unused: true, eqnull: true, laxbreak: true */

"use strict";
 * (function (module, window, $, mw) {

// Prevent double loads and respect prior double load check formatting if (!window || !$ || !mw || module.isLoaded || window.isUAALoaded) { return; } module.isLoaded = true;

// Protected namespace pseudo-enums Object.defineProperties(this, {

/**    * @description This pseudo-enum contains a pair of       *   properties containing the names of various element * selectors targeted by the script's various methods or applied to the new * user profile tab added by the script. The  property * contains the names of selectors added the UserActivityTab itself, while * the    contains jQuery-friendly * formatted selectors that are targeted for the retrieval of their text * content or used as parent nodes to which is added script-constructed * child HTML. *    * @readonly * @enum {object} */   Selectors: { enumerable: true, writable: false, configurable: false, value: Object.freeze({       NAMES: Object.freeze({

// UAA Id selectors ID_TAG_SPAN: "userAccountAge-span", ID_UAA_LINK: "userAccountAge-a",

// Tag class selectors CLASS_LEGACY_MASTHEAD_TAG: "tag", CLASS_UCP_MASTHEAD_TAG: "user-identity-header__tag", }),       TARGETS: Object.freeze({ LEGACY_MASTHEAD_HEADER: ".masthead-info h1", LEGACY_MASTHEAD_TAGS: ".masthead-info hgroup", UCP_MASTHEAD_TAGS: ".user-identity-header__attributes", })     }),    },

/**    * @description The   pseudo-enum contains a pair of     *   arrays as properties. The  array * contains the various  globals that are fetched and cached * via a  invocation later in the application, * while the  array contains the names of ResourceLoader * modules that are loaded via  at the start of     * the program's execution. *

*

* Of particular note is the new UCP-specific global called * . This global, along with its five similarly * prefixed cousins, only appears as a property of the *  on pages that display the user masthead. The presence * of this global is a clear indication that the user masthead will be lazy- * loaded at some point after DOM load, allowing the script to know to    *   and chill until the masthead deigns to make an     * appearance on the page. *    * @readonly * @enum {object} */   Dependencies: { enumerable: true, writable: false, configurable: false, value: Object.freeze({       GLOBALS: Object.freeze([ "profileUserName", "wgVersion", ]),       MODULES: Object.freeze([ "mediawiki.api", "mediawiki.util" ]),     })    },

/**    * @description The   pseudo-enum houses assorted * constants of various data types used through the program for various * purposes. It contains the  at which the script * scans the page for the user masthead, a  flag for * debug mode, and several  related to the script name * and the related  event name. *    * @readonly * @enum {number|boolean|string} */   Utility: { enumerable: true, writable: false, configurable: false, value: Object.freeze({       CHECK_RATE: 200,        DEBUG: false,        SCRIPT: "UserAccountAge",        HOOK_NAME: "dev.userAccountAge",      }), } });

/**  * @description This assembly method is used to assemble a link element within * an enclosing  exhibiting the requisite user tag class/id * selectors specific to the version of MediaWiki in use on the wiki. For the * purposes of simplicity, the outer containing  tag element * is provided both the UCP/MW 1.33 and the legacy MW 1.19 class names. As the * UCP class does not apply any styles on legacy wikis, this appears to have * not caused any noticable display issues. *  * @param {string} paramText - User tag text displayed * @param {string} paramTitle - User tag title on hover * @param {string} paramAddress - Link to API query confirming registration * @returns {string} - Assembled  HTML for appending */ this.assembleUserTag = function (paramText, paramTitle, paramAddress) { return mw.html.element("span", {     "id": this.Selectors.NAMES.ID_TAG_SPAN,      "class": [        "CLASS_LEGACY_MASTHEAD_TAG",        "CLASS_UCP_MASTHEAD_TAG"      ].map(function (paramName) { return this.Selectors.NAMES[paramName]; }.bind(this)).join(" "),   }, new mw.html.Raw( mw.html.element("a", {       "id": this.Selectors.NAMES.ID_UAA_LINK,        "href": paramAddress,        "title": paramTitle,      }, paramText) )); };

/**  * @description The   method of the *  object returns a   that passes *  user registration data upon a successful * resolve. It is invoked within the body of  in a   *   and is passed the username of the user as retrieved * from the header of the page masthead on legacy wikis or from the wg global *  property   on UCP wikis. *  * @param {string} paramUsername - Username about whom to retrieve data * @returns {object} -  promise object */ this.getRegistrationData = function (paramUsername) { return new mw.Api.get({     action: "query",      list: "users",      usprop: "registration",      ususers: paramUsername,      format: "json"    }); };

/**  * @description The   method is called once the script * initialization process handled by  has completed. This * method is used to load the registration data related to the currently * viewed user from an API query, wait until the masthead has loaded (if UCP), * then assemble and apply the custom user tag to the target element. *  is used to concurrently coordinate the loading of the * registration data with the loading of the masthead, the latter of which * makes use of  and a helper * to ensure that subsequent program flow does not occur until the masthead is  * loaded. *  * @returns {void} */ this.main = function  {

// Declarations var $helper, $getEssentials, interval, target, userData, date, dateString, dateInfo, formattedDate, tagText, address, tag;

// Definitions $helper = new $.Deferred; interval = null; target = this.Selectors.TARGETS[(this.info.isUCP) ? "UCP_MASTHEAD_TAGS" : "LEGACY_MASTHEAD_TAGS" ];

if (this.Utility.DEBUG) { window.console.log("target:", target); }

// Make initial call to progress before interval in case masthead exists $getEssentials = $.when(     this.getRegistrationData(this.info.userName),      $helper.notify.promise    );

// Continually check for presence of masthead via setInterval if (this.info.isUCP) { interval = window.setInterval($helper.notify, this.Utility.CHECK_RATE); }

/**    * @description The helper   is pinged via the use of     *   until the * masthead joins the party. Once it exists,  is     * resolved and execution continues to the   handler. */   $helper.progress(function  {      if (this.Utility.DEBUG) {        window.console.log("$helper.progress");      }

// Check for target, or check if interval (hence UCP) if (!$(target).length) { return; } else if (interval) { window.clearInterval(interval); }

// Resolve helper $.Deferred once masthead is found $helper.resolve; }.bind(this));

/**    * @description Once   resolves or rejects, the * associated  handlers are invoked accordingly. If the *    is resolved, meaning that the * masthead has been loaded and the registration data of the current user * has been successfully retrieved, the custom user tag is created via *  and appended to the tags group. */   $getEssentials.then(function (paramData) {      if (this.Utility.DEBUG) {        window.console.log(paramData);      }

// Specific user registration data userData = paramData[0].query.users[0];

// Reject malformed data or errors if (       paramData.error ||        userData.registration == null ||        userData.hasOwnProperty("missing") ||        userData.hasOwnProperty("invalid")      ) { return; }

if (this.Utility.DEBUG) { window.console.log(userData.registration); }

// Date definitions date = new Date(userData.registration); dateString = date.toString;

// Store date partials in object for piecemeal usage dateInfo = { dayWeek: dateString.slice(0, 3),      // "Fri" dayCalendar: dateString.slice(4, 15), // "Sep 01 2017" time: dateString.slice(16, 24),       // "19:37:07" };

// Example: "Fri, Sep 01 2017, 19:37:07" formattedDate = dateInfo.dayWeek + ", " + dateInfo.dayCalendar + ", " + dateInfo.time;

/* For whatever reason, $.timeago when invoked on UCP wikis no longer * returns any value apart from "NaN years ago", "a minute ago", or      * undefined. Until this issue is resolved (once the function returns a      * word-based summary), the UCP user tag will likely display a shortened * version of the formattedDate so the tag isn't rendered too long. */     tagText = $.timeago(date) || dateInfo.dayCalendar;

// Assemble link to formatted JSON data confirming registration address = mw.util.wikiScript("api") + "?" + $.param({       format: "jsonfm",        action: "query",        list: "users",        usprop: "registration",        ususers: userData.name,      });

// Build and log custom tag tag = this.assembleUserTag(tagText, formattedDate, address); if (this.Utility.DEBUG) { window.console.log(tag); }

// Inject CSS styling after assembly and prior to appending mw.util.addCSS(       "#" + this.Selectors.NAMES.ID_UAA_LINK + "{" +          "color: inherit !important;" +        "}"      );

// Add tag to target tags group $(target).append(tag); }.bind(this), window.console.error.bind(null, this.Utility.SCRIPT)); };

/**  * @description The   method is called once the requisite * ResourceLoader modules have been loaded and is tasked with setting up the * script in preparation for the creation and insertion of the custom tab by  *. In addition to the usual checks for the user * masthead and fetching/caching of required globals, the method makes use of  * the new   global   to determine if   * the UCP page being viewed is expected to lazy-load a masthead at some * indeterminate point in the future. If the  object has * this property (or any of its similarly prefixed cousins), the script can * expect that the masthead will appear at some point and plan accordingly to  * invoke   and wait until the masthead makes an   * appearance. *

*

* As an aside,  is a much cleaner way of getting * the username of the user whose page is being viewed than the legacy method, * which involves targeting the masthead header with jQuery and stripping the * text via. The method uses these two in concert as  * a means of determining if the masthead will appear&mdash;if the * ted value of   is   *   and the jQuery-targeted header text is an empty *, the script knows the current page is not a page on   * which a masthead will appear. *  * @returns {void} */ this.init = function  {

// Object for storage of informational data this.info = {};

// Cache globals this.globals = Object.freeze(mw.config.get(this.Dependencies.GLOBALS));

// Determine MW version this.info.isUCP = window.parseFloat(this.globals.wgVersion) > 1.19;

// Either username if user page (UCP et al.) or empty string if no masthead this.info.userName = (     this.globals.profileUserName ||      $(this.Selectors.TARGETS.LEGACY_MASTHEAD_HEADER).text    );

// Determine if masthead exists (indicates presence of userpage) this.info.hasMasthead = !!this.info.userName.length;

// Expose public methods for external debugging Object.defineProperty(module, "exports", {     enumerable: true,      writable: false,      configurable: false,      value: Object.freeze({ observeScript: window.console.dir.bind(this, this), })   });

// Return if no masthead expected to appear or if anon if (     !this.info.hasMasthead ||      mw.util.isIPv4Address(this.info.userName) ||      mw.util.isIPv6Address(this.info.userName)    ) { if (this.Utility.DEBUG) { window.console.log("return;"); }     return; }

// Dispatch hook with window.dev.mediaWikiBacklink once init is complete mw.hook(this.Utility.HOOK_NAME).fire(module).add(this.main.bind(this)); };

// Coordinate loading of all relevant dependencies $.when(mw.loader.using(this.Dependencies.MODULES), $.ready) .done(this.init.bind(this)) .fail(window.console.error.bind(null, this.Utility.SCRIPT));

}.call(Object.create(null), (this.dev = this.dev || {}).userAccountAge = this.dev.userAccountAge || {}, this, this.jQuery, this.mediaWiki));

importArticles({   type: 'script',    articles: [        /*        Extensions installed        Adding something which describes each one and whatever values I've changed.        For each thingy in here just get https://dev.fandom.com/wiki/ and copy-paste the name to get to its official page.        Some extensions I will give acronyms to. Assume, unless otherwise stated, that I personally use the extension, am happy with it, and I would only have it used by myself.        Note: Where an extension requires a lot of explanation or has its config settings changed, I will write a Note: String, where String is a random ID. Ctrl+F String to find a full explanation.        Acronyms used:        // PUO         –        Breaks Fandom's Customisation policy. Stands for Personal Use Only, as you're allowed to mess up your personal JS however you want.        // SWO         –        Can only be used site-wide // SW         –        I would recommend using this site-wide with ImportJS // VC         –        Values changed where they need to be. Will give it a Note: String. // SWVC       –        I would recommend this be used site-wide with certain customisations. Those will be commented where they need to be. // B          –        Only bots (or users who REALLY know what they are doing) should use this // NS         –        Not sure about permitting this one's existence // NU         –        I haven't really used this so I don't have an explanation/I've never seen it in action // TBC        –        I need to expand upon this. Probably mostly with SWVC. // BU         –        Buggy/doesn't work as intended, but not completely broken. Terms used: // Edity people    –      People with special editing rights. Locally, these are Admin and Content Mod. */

// To add extensions to ImportJS, copy the line and remove these parts: ', u:, MediaWiki:

/* Rollback/Spam prevention stuff Basically just there to stop spam/useless contributions*/ 'u:dev:MediaWiki:Rollback/code.js', 'u:dev:MediaWiki:AnchoredRollback/code.js', 'u:dev:MediaWiki:MassRollback.js', 'u:dev:MediaWiki:Nuke/code.js', 'u:dev:MediaWiki:AddBlockUserTag/code.js', /* Explanations of each: Rollback                            –        Does the Fandom default rollback that Fandom has, but instead of Tag:Rollback, it has (script) in the edit summary, which has a link to the script's page on DevWiki. Only works if you don't already have the permission. AnchoredRollback       SW           –        Means that when you press Rollback, it will just happen and you will just see the Rollback button disappear. NS because it takes away the weight of a rollback, but required for MassRollback. MassRollback           SW           –        Adds a Rollback All button on a user's contributions. Only works with Rollback and AnchoredRollback, and seemingly only usable by edity people. Nuke                   NU/SW        –        Deletes all pages created by a user. Can only be used by edity people implicitly. AddBlockUserTag        NU/SW        –        Adds a Block button to a user's masthead. Can only be used by blocky users implicitly. */

/* Page Controls Stuff that appears in the dropdown menu next to the edit button*/ 'u:dev:MediaWiki:CategoryRenameAuto-update/code.js', 'u:dev:MediaWiki:PageRenameAuto-update/code.js', 'u:dev:MediaWiki:FileUsageAuto-update/code.js', 'u:dev:MediaWiki:View_Source/code.js', 'u:dev:MediaWiki:WhatLinksHere/code.js', 'u:dev:MediaWiki:NullEditButton/code.js', /* Explanations of each: CategoryRenameAuto-update       B        –        For a category, renames it and then applies the rename to every link to it and all pages within it. Utterly floods RecentChanges. PageRenameAuto-update           B        –        Basically ↑ but for pages. Only available to the usual edity suspects. I'd assume the others are, too. FileUsageAuto-update            B        –        Basically ↑ but for Files. Need to use the queue button. View_Source WhatLinksHere                            –        Allows you to access the special page from Page Controls NullEditButton                           –        Clears cache and does other stuff perhaps */

/* My Tools Stuff that appears in the My Tools menu at the bottom of the screen*/ 'u:dev:MediaWiki:MassEdit/code.js', 'u:dev:MediaWiki:MassCategorization/code.js', 'u:dev:MediaWiki:MassRename/code.js', 'u:dev:MediaWiki:MassRenameRevert/code.js', 'u:dev:MediaWiki:AjaxBatchDelete.js', 'u:dev:MediaWiki:AjaxBatchUndelete.js', /* Explanations of each: MassEdit                                   –       Does a lot. Only usable by edity people. 4 modes: Find and replace content, Add new content, Message users, Generate page listing. Note X8OhH. MassCategorization                         –       Can add, remove and replace categories where you give it the pages to. You can also add every page in a certain category to the list. Duplicate detector in Add is buggy. MassRename                     NU          –       Allows you to rename a lot of pages in quick succession. Format is Current_Name New_Name for each line. Limited use for non-edity people. MassRenameRevert               NU/NS       –       Opens tabs to revert renaming of every checked rename. Hampered by Popup blockers. AjaxBatchDelete                NU          –       Deletes all pages. Format is same as MassEdit. Only usable by edity people implicitly. AjaxBatchUndelete              NU/NS       –       ↑ but the opposite. Not sure because only edity people, who should be trusted, can delete stuff. Note: All of these besides MassRenameRevert would be flagged as B, but it's more aesthetic to just put this as a note down here */

/* Help Stuff that I find to be generally quite helpful (sometimes theoretically), mostly just small QOL things*/ 'u:dev:MediaWiki:CopyTitle.js', 'u:dev:MediaWiki:DupeArgs.js', 'u:dev:MediaWiki:EditConflictAlert/code.js', 'u:dev:MediaWiki:NotesModule/code.js', 'u:dev:MediaWiki:MassProtect/code.js', 'u:dev:MediaWiki:DecodeURI/code.js', 'u:dev:MediaWiki:FastFileDelete.js', 'u:dev:MediaWiki:CategoryQuickRemove.js', 'u:dev:MediaWiki:AddArticleToCategory/code.js', 'u:dev:MediaWiki:AjaxRename/code.js', 'u:dev:MediaWiki:AjaxUndo/code.js', 'u:dev:MediaWiki:QuickTitle/code.js', 'u:dev:MediaWiki:AjaxUserRights.js', 'u:dev:MediaWiki:BotManagement.js', 'u:dev:MediaWiki:MassBlock/code.js', 'u:dev:MediaWiki:ToDoList.js', 'u:dev:MediaWiki:ColorPreview/code.js', 'u:dev:MediaWiki:UploadMultipleFiles.js', /* Explanations of each: CopyTitle                          –       Adds two buttons to the top of the page. Top copies title, bottom copies namespace and title. DupeArgs               NU          –       In My Tools, adds a thing for resolving templates using duplicate arguments. EditConflictAlert                  –       Notifies you when the page you are editing gets edited by somebody else. NotesModule            PUO/BU      –       Adds a Notes section above the Recent Changes sidebar. Have to refresh to save changes and you can only have 1 at a time. Still kinda useful. MassProtect            NU          –       Allows you to protect many pages at once. Seems to be the same format as MassEdit etc. Perhaps SW/B? FastFileDelete         NU/SW       –       Adds a 'delete' button to Special:UnusedFiles/Videos and the lightbox (the one that shows when you click an image). Edity people only. CategoryQuickRemove    SW          –       Adds an X next to categories, allowing you to delete them without editing. AddArticleToCategory   SW          –       Adds an Add to Category link in each category page AjaxRename             NU          –       Broken? AjaxUndo               VC          –       Allows you to undo an edit without moving page, like anchored rollback but as an undo. Note SVsrn. QuickTitle                         –       Allows you to edit the  by just clicking on the title. Annoying crossover with CopyTitle but whatever. AjaxUserRights         NU          –       I think you already know what this is. BotManagement          NU/B/VC     –       Adds buttons to add/remove bot rights. Perhaps superfluous with AjaxUserRights. Note sLgrH. MassBlock              NU/B        –       Allows you to block a list of users. Because why not. ToDoList               PUO/VC      –       Hijacked. On the bottom bit where My Tools also is. Note 1Vzz1. */

//Visual stuff 'u:dev:MediaWiki:MarkBlocked.js', 'u:dev:MediaWiki:ProtectionIcons.js', 'u:dev:MediaWiki:PatrolPanel.js', 'u:dev:MediaWiki:ProtectedHighlight/code.js', 'u:dev:MediaWiki:FixWantedFiles/code.js', //Fun 'u:dev:MediaWiki:FirstEditDate.js', 'u:dev:MediaWiki:GlobalEditcount/code.js', 'u:dev:MediaWiki:ShowUserGroups.js', 'u:dev:MediaWiki:MastheadGender/code.js', 'u:dev:MediaWiki:RevealAnonIP/usercode.js', 'u:dev:MediaWiki:UserRightsRecord/code.js', //       'u:dev:MediaWiki:UserAccountAge/code2.js', 'u:dev:MediaWiki:UserAndIPTools.js', 'u:dev:MediaWiki:ShowWROnToolbar.js', //Pretty cool 'u:dev:MediaWiki:EditLeaderboard.js', 'u:dev:MediaWiki:NavCodeLinks/code.js', 'u:dev:MediaWiki:AnalyticsShortcut.js', 'u:dev:MediaWiki:StickySummary.js', 'u:dev:MediaWiki:AddUserRightsTag/code.js', 'u:dev:MediaWiki:MassUserRights/code.js', 'u:dev:MediaWiki:CatNav/code.js', 'u:dev:MediaWiki:ImportJSPage/code.js', // ?       'u:dev:MediaWiki:PortableListUsers.js', 'u:dev:MediaWiki:GlobalJSLinks.js', 'u:dev:MediaWiki:RemoveTracking.js', 'u:dev:MediaWiki:MassPatrol/code.js', 'u:dev:MediaWiki:MassNullEdit/code.js', 'u:dev:MediaWiki:AjaxDelete/code.js', 'u:dev:MediaWiki:Bang.js', 'u:dev:MediaWiki:Sofix.js', 'u:dev:MediaWiki:DisableCode/code.js', // DisableCode                    NS          –       Allows me to disable JS for reasons unknown

//'u:dev:MediaWiki:Deadvideo/code.js', /* Common.js but not personal use UserBadge*/ /* Sitewide PreloadTemplates ProfileTags DisableBotMessageWalls Standard_Edit_Summary *//* Others CSSMessageWallTags */   ] });

// This stuff will break the entire program if it's before window.dev.forceRemoveTracking = true;

/*X8OhH (MassEdit) Explanation of each individual mode of MassEdit Find and replace content               –       Defaults I've never changed: Select Type, Select Matching, Specific Instances. Seems to have certain limitations I don't know for now. To use:                        Must insert a list of pages into the Page Entries section. Put in your text in the Target Content bit. Put the replacey stuff in the New Content bit. Press submit. Also, you can put in an edit summary.

Add new content                NU      –       I assume with Select Action that Prepend adds to the start and Append adds to the end of the page. Everything else looks as in Find and replace. Message users                  NU      –       I assume it's exactly as it says on the tin. Generate page listing                  –       NU namespace. For C, it lists all pages in the Category. For T, it lists all pages that use that template.

/* note for later:
 * Help:Lua|Lua
 * Global Lua Modules|Global Modules
 * Lua templating/Converting Wikitext templates|Converting to Lua
 * Lua reference manual|Lua Documentation
 * Lua reference manual/Standard libraries|Standard libraries
 * Lua reference manual/Scribunto libraries|Scribunto libraries

/* Additional notes https://www.random.org/strings/?num=1&len=5&digits=on&upperalpha=on&loweralpha=on&unique=on&format=html&rnd=new MediaWiki:Group-sysop.js