User:He7d3r/Tools/AddActionLinks.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// [[File:User:He7d3r/Tools/AddActionLinks.js]] (workaround for [[phab:T35355]])
/**
 * Adds "edit", "hist" and "delete" link to [[Special:WhatLinksHere]] and the list of templates used in a page
 * @author: Helder (https://github.com/he7d3r)
 * @license: CC BY-SA 3.0 <https://creativecommons.org/licenses/by-sa/3.0/>
 * Based on [[mw:Snippets/Special:WhatLinksHere action links]] (rev 2)
 */
// <nowiki>
(function(i,e){"use strict";function t(t){var a={history:"hist"},n={};e.inArray("delete",t)!==-1&&(a["delete"]="elim"),i.config.get("wgCanonicalSpecialPageName")?(a.edit="editar",n.items="#mw-whatlinkshere-list li",n.link=".mw-whatlinkshere-tools a:last"):(n.items="#editform .templatesUsed li",n.link="a:last"),e(function(){e(n.items).each(function(){var t,r=e(n.link,this),s=i.config.get("wgScript")+"?title="+encodeURIComponent(e("a:first",this).text())+"&action=";for(t in a)r.after(e("<a>").attr("href",s+t).text(a[t])).after(" | ")})})}(i.config.get("wgCanonicalSpecialPageName")==="Whatlinkshere"||e.inArray(i.config.get("wgAction"),["edit","submit"])!==-1)&&i.loader.using("mediawiki.user",function(){i.user.getRights(t)})})(mediaWiki,jQuery);
// </nowiki>