-
Notifications
You must be signed in to change notification settings - Fork 3
/
WatchDoc.js
32 lines (25 loc) · 950 Bytes
/
WatchDoc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*** Watch Doc ***/
// Watch the documentation page of a template when you watch the template
// Documentation at [[en:w:User:BrandonXLF/WatchDoc]]
// By [[en:w:User:BrandonXLF]]
$(function() {
var namespace = mw.config.get('wgNamespaceNumber'),
title = mw.config.get('wgPageName'),
watchlink = $('#ca-watch a, #ca-unwatch a');
if (namespace !== 10 && namespace !== 11 || title.includes('/doc')) return;
watchlink.click(function() {
mw.loader.using('mediawiki.page.watch.ajax').then(function(require) {
var clone = watchlink.clone().removeClass('loading'),
oldNotify = mw.notify;
mw.notify = function(msg, opts) {
// Both the doc and non-doc messages need to be shown...
if (~msg.text().indexOf(title + '/doc')) opts.tag += '-doc';
oldNotify(msg, opts);
};
require('mediawiki.page.watch.ajax').watchstar(clone, title + '/doc', function() {
mw.notify = oldNotify;
});
clone.click();
});
});
});