User:PrimeHunter/Impact.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 a tools link saying "Impact" to [[Special:Impact/X]]
   when you are in the userspace of the user X.
   IP's don't have impact pages but the script makes a broken link for them.
   To use the script, add the following line to Special:MyPage/common.js:
 
importScript('User:PrimeHunter/Impact.js'); // Linkback: [[User:PrimeHunter/Impact.js]]
 
*/
 
$( document ).ready( function() {
  if (mw.config.get('wgNamespaceNumber') != "2" && mw.config.get('wgNamespaceNumber') != "3")
      return;  // restrict to User and User talk

  mw.util.addPortletLink(
    'p-tb',
    mw.util.getUrl( 'Special:Impact/' ) + mw.config.get('wgRelevantUserName'),
    'Impact',
    't-impact',
    'Show subpages of the current page',
    null,
    '#t-info'
  );
});