Jump to content

User:Amorymeltzer/wlhActionLinks.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//Modified version of [[meta:User:He7d3r/Tools/AddActionLinks.js]]
//https://meta.wikimedia.org/w/index.php?title=User:He7d3r/Tools/AddActionLinks.js&oldid=12463106
//Only on [[Special:WhatLinksHere]], made English, removed edit link, swapped hist and delete
//Do things more Amory-esque, i.e. worse

if (mw.config.get('wgCanonicalSpecialPageName') === "Whatlinkshere") {
    var items = $("#mw-whatlinkshere-list li");
    $.each(items, function(k, item) {
	var itemz = $(item).find('a')[0];

	var histLink = $(itemz).clone(true);
	histLink.text("hist");
	histLink.attr('href', "/w/index.php?title=" + encodeURI(itemz.title) + "&action=history");

	if ($.inArray('sysop', mw.config.get('wgUserGroups')) !== -1) {
	    var delLink = $(itemz).clone(true);
	    delLink.text("del");
	    delLink.attr('href', "/w/index.php?title=" + encodeURI(itemz.title) + "&action=delete");

	    delLink.insertAfter($(item).find('a')[2]).before(" | ");
	}
	histLink.insertAfter($(item).find('a')[2]).before(" | ");
    });
}