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.
// Adds [watch] after [purge] in the documentation links
// Clicking on [watch] will watch the /doc page
//
jQuery(document).ready(function($) {
mw.loader.using(['mediawiki.util']).done( function() {
var span_element = document.getElementById('doc_editlinks');
if(span_element && span_element.innerHTML.search(/\[<a[^<>]*action=history[^<>]*>[^<>]*<\/a>\]/g) >= 0) {
  var watch_link = span_element.innerHTML.replace(/^.*(\[<a[^<>]*action=history[^<>]*>[^<>]*<\/a>\]).*$/, '$1');
  watch_link = watch_link.replace(/action=history/, 'action=watch');
  watch_link = watch_link.replace(/>history</, '>watch</');
  span_element.innerHTML = span_element.innerHTML + ' ' + watch_link;
}
});
});