User:CowHammer/Scripts/wikilinkify.js

From RationalWiki
Jump to navigation Jump to search

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.
function wikilinkify()
{
  document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/\[http:\/\/en.wikipedia.org\/wiki\/([^\s]*)([^\]]*)/g, "[[WP:$1 |$2]");
  var re = new RegExp("/\[WP:.*\]/g");
  document.editform.wpSummary.value = "Bare wikipedia.org links -> WP: links by (partially working) [[:User:CowHammer/Scripts/wikilinkify.js | Wikilinkify script]]";
  document.editform.wpMinoredit.checked = true;
  document.editform.wpDiff.click();
  //document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(re, decodeURIComponent(re));
}

addOnloadHook( function () {
  addPortletLink( 'p-cactions', 'javascript:wikilinkify()', 'Wikilinkify', 'ca-wikilinkify', 'Convert bare WP links to WP: links' );
});