User:Anerisys/contribution shortcuts for MediaWiki 2019-2021.js

/* "edit" and "info" shortcuts to Special:contributions for MediaWiki versions released approximately from 2019 to 2021. To be merged with the main script. */

var contribution_day = 0; var contribution_count = 0; var contributions_on_page = 0;

// localization var language = mw.config.values.wgPageContentLanguage; var l10n_base = { en: { 'edit': 'edit', 'info': 'info' },	de: { 'edit': 'Bearbeiten', 'info': 'Informationen' } }; function l10n(msg) { return l10n_base[language][msg]; }

var contribution_list = document.querySelector(".mw-contributions-list").getElementsByTagName("li");

for ( contribution_count = 0; contribution_count < contribution_list.length; contribution_count++ ) { var contribution=contribution_list[contribution_count];

edit_page_URL = mw.util.getUrl( contribution.querySelector(".mw-contributions-title").innerHTML, { "action": "edit" } ); info_page_URL = mw.util.getUrl( contribution.querySelector(".mw-contributions-title").innerHTML, { "action": "info" } );

// add "edit" shortcut contribution.querySelector(".mw-changeslist-links").appendChild(document.createElement("span")); contribution.querySelector(".mw-changeslist-links").lastElementChild.classList.add("mw-changeslist-edit"); contribution.querySelector(".mw-changeslist-links").lastElementChild.innerHTML=' '+l10n("edit")+'';

// add "info" shortcut contribution.querySelector(".mw-changeslist-links").appendChild(document.createElement("span")); contribution.querySelector(".mw-changeslist-links").lastElementChild.classList.add("mw-changeslist-info"); contribution.querySelector(".mw-changeslist-links").lastElementChild.innerHTML=' '+l10n("info")+'';

contributions_on_page+=1; }