Article snapshot taken from Wikipedia with creative commons attribution-sharealike license.
Give it a read and then ask your questions in the chat.
We can research this topic together.
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
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 Misplaced Pages:Bypass your cache.
// the usual prayer
if (mw.config.get('wgCanonicalSpecialPageName') == "Contributions" || mw.config.get('wgNamespaceNumber') == 14)
mw.loader.using('mediawiki.api', function() { $(function() {
function i18n(key) {
switch (mw.config.get('wgUserLanguage')) {
case 'he':
switch (key) {
case 'watch':
return '';
case 'unwatch':
return ''
case 'watchhint':
return 'הוסף לרשימת המעקב שלי';
case 'unwatchhint':
return 'הסר מרשימת המעקב שלי';
case 'showwatchlinks':
return 'הצג קישוריות מעקב';
}
break;
default:
switch (key) {
case 'watch':
return '';
case 'unwatch':
return ''
case 'watchhint':
return 'Add to my Watchlist';
case 'unwatchhint':
return 'Remove from my watchlist';
case 'showwatchlinks':
return 'Show watchlist controls';
}
break;
}
return key;
}
var isCat = mw.config.get('wgNamespaceNumber') == 14,
watchList = {},
api = new mw.Api();
function readWatchList(continuation) {
var params = {list: 'watchlistraw', wrlimit: 500, rawcontinue: ''};
if (continuation)
params.wrcontinue = continuation;
api.get(params, function(data) {
if (data && data.watchlistraw)
$.each(data.watchlistraw, function(key, val) { watchList = true; });
if (data && data)
readWatchList(data);
else
colorWatched();
});
}
function watchText(watch) { return (isCat ? ' ':'') + i18n(watch ? 'watch' : 'unwatch');}
function watchTitle(watch){ return i18n(watch ? 'watchhint' : 'unwatchhint');}
function colorWatched() {
var pagesList = isCat ? $('#mw-pages').find('li') : mw.util.$content.find('ul > li');
var all = ;
var all = pagesList.each(function() {
var li = $(this);
var line = li.children().filter('a:last');
var page = line.attr('title');
var watched = watchList || false;
if (watched)
line.addClass('iswatched');
var watchLink = $('<span>', {'class': watched? 'unwatchit-link' : 'watchit-link', title: watchTitle( !watched)})
.text(watchText(! watched))
.click(function() {watchIt($(this), page)})
li.append(watchLink);
});
}
function watchIt(span, page) {
var watched = span.hasClass('unwatchit-link');
api(page, function() {
var lines=$('a').filter(function(){return $(this).text()==page});
lines.parent().children('span.watchit-link, span.unwatchit-link')
.toggleClass('unwatchit-link watchit-link')
.text(watchText(watched))
.attr({title: watchTitle(watched)});
lines.toggleClass('iswatched');
});
}
mw.util.addCSS(
".unwatchit-link{color:#a00; cursor: pointer; font-size: 70%;display:none} \n" +
".watchit-link{color:#008; cursor: pointer; font-size: 70%;display:none} \n" +
".iswatched{font-weight: bolder;} \n" +
"</style> "
)
readWatchList();
var showLink = $('<a>', {href: '#', text: i18n('showwatchlinks')}).click(
function(){
mw.util.addCSS('.unwatchit-link,.watchit-link{display:inline;}');
$(this).remove();
}
);
if ($('#contentSub a').length)
$('#contentSub a:last').after(showLink).after(' | ');
else
$('#contentSub').append(showLink);
})}); // using ... ready