Jump to content

User:PrimeHunter/Where links this.js

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by PrimeHunter (talk | contribs) at 12:28, 24 September 2024 (add link brackets to Special:MyPage/common.js so it renders as a link). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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.
/* This script adds "Where links this" below "What links here" in the sidebar.
   It shows an unlinked list of up to 500 pages linked from the current page.
   To use the script, add the following line to [[Special:MyPage/common.js]]:
 
importScript('User:PrimeHunter/Where links this.js'); // Linkback: [[User:PrimeHunter/Where links this.js]]

*/

mw.loader.using(['mediawiki.util'], function () {
  mw.util.addPortletLink(
    'p-tb',
    'https://en.wikipedia.org/w/api.php?action=query&prop=links&pllimit=500&format=xml&titles=' +
      encodeURIComponent(mw.config.get( 'wgPageName' )),
    'Where links this',
    'pt-outlinks',
    'What does this page link to',
    null,
    '#t-recentchangeslinked'
  );
});