User:Frietjes/watchdoc.js

// 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(/\[]*action=history[^<>]*>[^<>]*<\/a>\]/g) >= 0) { var watch_link = span_element.innerHTML.replace(/^.*(\[]*action=history[^<>]*>[^<>]*<\/a>\]).*$/, '$1'); watch_link = watch_link.replace(/action=history/, 'action=watch'); watch_link = watch_link.replace(/>historywatch</'); span_element.innerHTML = span_element.innerHTML + ' ' + watch_link; } }); });