User:PrimeHunter/Where links this.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.
/* 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'
  );
});