User:GuyThatExists/common.js

From Drawn to Life Wiki
You are viewing a page within the User namespace. These pages are typically designated for user-generated content, and should not be confused for canon.

Note: After saving, 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: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* This script adds "Source links" below "What links here" in the sidebar.
   "What links here" will include pages using a template with the link.
   "Source links" tries to search for pages where the link is in the source.
   To use the script, add the following line to Special:MyPage/common.js:
 
importScript('User:PrimeHunter/Source links.js'); // Linkback: [[User:PrimeHunter/Source links.js]]

*/

mw.loader.using(['mediawiki.util'], function () {
  var name = mw.config.get( 'wgPageName' ).replace("Special:WhatLinksHere/", "");
  mw.util.addPortletLink(
    'p-tb',
    mw.util.getUrl( 'Special:Search' ) + '?profile=all&search=' +
    encodeURIComponent('linksto:"' + name + '" ' + 'insource:"' + name + '" ' +
    'insource:/\\[\\[:?[' + name[0] + name.charAt(0).toLowerCase() + ']' +
    name.substring(1).replace(/[-[\]{}()*+!<=:?.\/\\^$|#\s,]/g, '\\$&') + '[\\]\\|#]/' ).replace(/_/g, " "),
    'Source links',
    'pt-sourcelinks',
    'What links here in the source',
    null,
    '#t-recentchangeslinked'
  );
});