User:StrawberryMaster/global.js

/** * This file loads for myself. * For skin specific variants see User:StrawberryMaster/monobook.js and User:StrawberryMaster/wikia.js * for monobook and oasis respectively * * Please test any changes made to this file. * Jshint  can catch syntax errors to help testing. * Alternatively, Wikia's code editor has jshint embedded to make life extra simple. * * The scripts here follow Wikia JS guidelines or MediaWiki coding standards where the Wikia * guidelines do not specify: * -  * -  * * The scripts have extremely high usage across Wikia, please do not deploy without * extensive testing. Be aware that these scripts must be ES3 compliant due to the * minifier used by ResourceLoader. * * The majority of the scripts here are for personal use as they modify parts of the Oasis/Monobook skin violating Wikia's Terms of Use. * * All rights to go their respective owners (Dorumin, Slyst, Cheeseskates, Cqm, viz., other users not mentoned). * * As of August 28, 2017, this is version 70. */ /* Adds an 'AJAX UNDO' link next into the undo link on page histories/diff pages. * Something I found on Dorumin's global.js.  * See w:c:dev:AjaxUndo (stable?) for info & attribution. */ (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;    }

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); /////////////////////////////////////////////////////////////////////////////// /**/ ///————————————————————— Minor Direct JavaScript code ———————————————————————/// /**/ /////////////////////////////////////////////////////////////////////////////// /* Everything starting from this line to line 351 belongs to Cheeseskates. */

// Add an edit links on Special:WhatLinksHere if (mw.config.get("wgCanonicalSpecialPageName") === "Whatlinkshere") { $("#mw-whatlinkshere-list > li").each(function(dataAndEvents, context) {   var fontSize = $(context).children("a").attr("href") + "?action=edit";    $(context).find(".mw-whatlinkshere-tools > a:last-child").after(" | ", $("").attr("href", fontSize).text("edit"));  }); } // Add a history button on diff pages if ($('strong:contains("Changes:")').length) { $("#WikiaPageHeader").find("p").children("a").after(' (history)'); } // Add a powerusers checkbox in Special:ListUsers if (wgCanonicalSpecialPageName == "Listusers") { $("fieldset.lu_fieldset tr:last-child").prepend('  Power Users '); } // Add a separate list of uncreated categories on Special:Categories if (mw.config.get("wgCanonicalSpecialPageName") === "Categories") { var $newCats = $(" ").css("float", "right").text("Uncreated categories:"); var $newCatsList = $("").appendTo($newCats); $(".mw-spcontent > ul").before($newCats); $(".mw-spcontent > ul > li").has(".newcategory").clone.appendTo($newCatsList); } // Disable the 5 sec. edit save delay $(function { $("#editform").off("submit").on("submit", function { $(window).unbind(".leaveconfirm"); }); });

/////////////////////////////////////////////////////////////////////////////// //———————————————————————————————————————————————————————————————————————————— // Script Configurations /* All of the confgurations below contribute to how the JavaScript imports function. It only works with imports like this, not direct JavaScript code, hence why it is in between here and the mentioned section above. */ //————————————————————————————————————————————————————————————————————————————

///////////////////////////////////////////////////////////////////////////////

/* Auto updating recent changes opt-in. * Something I found on Dorumin's global.js.  * See w:c:dev:AjaxRC for info & attribution. */ window.ajaxRefresh           = 1E3; window.AjaxRCRefreshText     = 'Auto-refresh'; window.AjaxRCRefreshHoverText = 'Automatically refresh the page'; window.ajaxPages = [ /// // ——————————————————— Temporary Watchlist (for vandals) ———————————————————— / /// //Add below when necessary. /* all script credit goes to Cheeseskates */ /*———————————————————————————————————————————————————————————————————————————————— ———————————————————————————————————————————————————————————————————————————————— /* ////* Afrikaans (af) *//// "Spesiaal:WikiActivity", "Spesiaal:Onlangse_wysigings", "Spesiaal:Logboek", ////* Arabic (العرب) (ar) *//// "خاص:WikiActivity", "خاص:أحدث_التغييرات", "خاص:سجل", ////* Belorussian (Беларуская) (be) *//// "Адмысловае:WikiActivity", "Адмысловае:RecentChanges", "Адмысловае:Log", ////* Brazilian Portuguese (Português do Brasil) (pt-br) *//// "Especial:Mudanças_recentes", ////* Bulgarian (Български) (bg) *//// "Специални:WikiActivity", "Специални:Последни_промени", "Специални:Дневници", ////* Catalan (Català) (ca) *//// "Especial:Canvis_recents", "Especial:Registre", ////* Chinese (中文) (zh) *//// "Special:最近更改", "Special:日志", ////* Chinese (Taiwan) ( 中文(台灣) ) (zh-tw) *//// "特殊:WikiActivity", "特殊:近期變動", "特殊:日誌", ////* English (en) *//// "Special:WikiActivity", "Special:RecentChanges", "Special:Watchlist", "Special:AbuseLog", "Special:Log", "Special:Log/upload", "Special:Images", "Special:Videos", "Special:Newwikis", "Report:Vandalism", "Report:Spam", "Report:User profile headers", "Report:Users and IPs needing checked", ////* Estonia (Eesti) (et) *//// "Eri:WikiActivity", "Eri:Viimased_muudatused", "Eri:Logid", ////* Farsi (فارسی) (fa) *//// "ویژه:WikiActivity", "ویژه:تغییرات_اخیر", "ویژه:سیاهه‌ها", ////* French (Français) (fr) *//// "Spécial:WikiActivity", "Spécial:Modifications_récentes", "Spécial:Journal", ////* Galician (Galego) (gl) *//// "Especial:Cambios_recentes", "Especial:Rexistros", ////* German (Deutsch) (de) *//// "Spezial:WikiActivity", "Spezial:Letzte_Änderungen", "Spezial:Logbuch", ////* Greek (Ελληνικά) (el) *//// "Ειδικό:WikiActivity", "Ειδικό:ΠρόσφατεςΑλλαγές", "Ειδικό:Μητρώο", ////* Hungarian (Magyar) (hu) *//// "Speciális:WikiActivity", "Speciális:Friss_változtatások", "Speciális:Rendszernaplók", ////* Indonesian (Bahasa Indonesia) (id) *//// "Istimewa:WikiActivity", "Istimewa:Perubahan_terbaru", "Istimewa:Catatan", ////* Italian (Italiano) (it) *//// "Speciale:WikiActivity", "Speciale:UltimeModifiche", "Speciale:Registri", ////* Japanese (日本語) (ja) *//// "特別:WikiActivity", "特別:最近の更新", "特別:ログ", ////* Korean (한국어) (ko) *//// "특수기능:위키활동내역", "특수기능:최근바뀜", "특수기능:기록", ////* Limburg (Limburgs in Dutch) (li) *//// /* Note: Wikiactivity is the same as the Nederlands' WikiActivity page, so it is not included. */ "Speciaal:Lètste_verangeringe", "Speciaal:Logbeuk", ////* Lithuanian (Lietuvių) (lt) *//// "Specialus:WikiActivity", "Specialus:Naujausi_keitimai", "Specialus:Sąrašas", ////* Nederlands (nl) *//// "Speciaal:WikiActivity", "Speciaal:RecenteWijzigingen", "Speciaal:Logboeken", ////* Norwegian Bokmål ( ‪Norsk (bokmål) ‬) (no) *//// "Spesial:WikiActivity", "Spesial:Siste_endringer", "Spesial:Logg", ////* Occitan (oc) *//// "Especial:Darrièrs_cambiaments", "Especial:Jornal", ////* Polish (Polski) (pl) *//// "Specjalna:Aktywność_na_wiki", "Specjalna:Ostatnie_zmiany", "Specjalna:Rejestr", ////* Russian (Русский) (ru) *//// "Служебная:WikiActivity", "Служебная:RecentChanges", "Служебная:Log", ////* Romanian (Română) (ro) *//// "Special:Schimbări_recente", "Special:Jurnal", ////* Serbian / serbian (Српски / Srpski) (sr) *//// "Посебно:WikiActivity", "Посебно:СкорашњеИзмене", "Посебно:Извештај", ////* Spanish (Español) (es) *//// "Especial:WikiActivity", "Especial:CambiosRecientes", "Especial:Registro", ////* Suomi (Finnish) (fi) *//// "Toiminnot:WikiActivity", "Toiminnot:Tuoreet_muutokset", "Toiminnot:Loki", ////* Ukrainian (Українська) (uk) *//// "Спеціальна:WikiActivity", "Спеціальна:RecentChanges", "Спеціальна:Log", ////* Vietnamese (Tiếng Việt) (vi) *//// "Đặc_biệt:Hoạt_động_wiki", "Đặc_biệt:Thay_đổi_gần_đây", "Đặc_biệt:Nhật_trình" //// // —————————————————————————— End AjaxRC Section ———————————————————————————— // //// ];
 * // Interlanguage Wiki Pages //                           |
 * Note 1: The order is according to the Language Brigade Wiki and alphabetical.   |
 * Note 2: The first language name is the English word. The second language        |
 * name is the language's word/original word. The two letters after are the        |
 * abbreviations for the second language names.                                    |
 * 1. Always add the language names in this order: English word -> Original ↓      |
 * -> Abbreviation (e.g. fr for french)                                            |
 * 2. Always add the page names in this order: WikiActivity -> RecentChanges -> Log |
 * Note 3: The Chinese and Romanian's WikiActivity are the same as the English     |
 * WikiActivity page, and the Brazilian Portuguese (including their Log page),     |
 * Catalan, Galician, and occitan's WikiActivity are the same as the Spanish       |
 * WikiActivity page. Because of this, They are not added to prevent duplication.  |
 * WikiActivity page, and the Brazilian Portuguese (including their Log page),     |
 * Catalan, Galician, and occitan's WikiActivity are the same as the Spanish       |
 * WikiActivity page. Because of this, They are not added to prevent duplication.  |

// AjaxDelete Configuration window.AjaxDelete = { deleteReasons: { "w:Help:Vandalism"      : "Vandalism", "w:Help:Spam"           : "Spam", "Marked for speedy deletion" : "Speedy", "Empty page"                : "Empty", "Author's request"          : "Author request", "Irrelevant to " : "Irrelevant" }, imageDeleteReasons: { "Offensive"                 : "Offensive", "inappropriate"             : "inappropriate", "Harassment"                : "Harassment", "Housekeeping/Unused"       : "Unused", "Copyright infringement"    : "Copyright", "Author's request"          : "Author request" }, autoCheckWatch: false, noUndelete: true }; /* Create userpage script. * See w:c:dev:QuickCreateUserPage for info & attribution. */

window.qtUserPageTemplate = ''; window.qtEnableUserPageOverwrite = true;

/* Vector skin configuration. * See w:c:dev:Pseudo-Vector JS for info & attribution. */ window.pseudoVector = { loadCss: true, addReadTab: true, addContributionsTab: true, disableWatchIcon: false, visualEditorIcons: true };

/* Removes backlinks from pages. * See w:c:dev:Linksweeper for info & attirbution. */ window.linkSweepConfirmation = true; window.LinkSweeperDelay = 1000;

/* Places "QuickToolsv2" button on the "My Tools" section. * Something I found on Zmario's global.js. <c:User:Zmario/global.js> * See w:c:dev:QuickToolsv2 for info & attribution. */ window.QuickToolsAdvancedtop = false;

// AutoFormatter Configuration var autoFormatWikimediaLinks   = true;  // Format localized hyperlink syntax var autoFormatLocalisation     = true;  // Format deprecated keywords and syntaxes var autoFormatMaskedLinks      = false; // Format masked hyperlinked text var autoFormatShortYearRanges  = true;  // Format year ranges

///////////////////////////////////////////////////////////////////////////////

//———————————————————————————————————————————————————————————————————————————— // Imports /* Imports minify the rest of the JavaScript or CSS code and combines multiple HTTP requests into a single data transfer, making it save space and load faster than direct code. It is recommended to import this way. */ //———————————————————————————————————————————————————————————————————————————— /////////////////////////////////////////////////////////////////////////////// /* again, header credit goes to Cheeseskates */

//--- /* importscriptURL */ //--- // Advisor - Helps with editing suggestions such as whitespace removal, headings nest, etc. importScriptURI("https://en.wikipedia.org/w/index.php?title=User:Cameltrader/Advisor.js&action=raw&ctype=text/javascript"); // AutoFormatter - Formats a page automatically to fix common mistakes in wiki-markup importScriptURI("https://de.wikipedia.org/w/index.php?title=Benutzer:TMg/autoFormatter.js&action=raw&ctype=text/javascript"); // AutoLink - Parses wikilinks, [external links], {templates}, and URLs into clickable links importScriptURI("https://en.wikipedia.org/w/index.php?title=User:Lenore/autolink.js&action=raw&ctype=text/javascript");

//--- /* importArticles */ //---

$(function {   importArticles({ type: 'script', articles: [ // ...           'u:dev:MediaWiki:AjaxRC/code.js', // Special:RecentChanges live update 'u:dev:MediaWiki:AjaxBlock/code.js', // Blocks users quickly 'u:dev:MediaWiki:AjaxDelete/code.js', 'u:dev:MediaWiki:AjaxPatrol/code.js', 'u:dev:MediaWiki:Linksweeper/code.js', 'u:dev:MediaWiki:MassBlock/code.js', 'u:dev:MediaWiki:MassCategorization/code.js', 'u:dev:MediaWiki:MassUserRights/code.js', 'u:dev:MediaWiki:Pseudo-Vector.js', 'u:dev:MediaWiki:QuickCreateUserPage/code.js', 'u:dev:Mediawiki:QuickToolsv2/code.js', // Quick tools 'u:dev:MediaWiki:UTCClock/code.js', // Show UTC clock 'u:monchbox:MediaWiki:Torus.js' // ...       ]	}); });

/* - END of User:StrawberryMaster/global.js */ console.info('Loaded User:StrawberryMaster/global.js version 70');