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.
//User:NQ/WatchlistResetConfirm.js
mw.loader.using(['mediawiki.api', 'oojs-ui'], function() {
$watchlistReset = $('#mw-watchlist-resetbutton');
$watchlistReset.insertAfter('#watchlist-message');
$watchlistReset.css({'display': 'inline', 'float': 'right'});
var messageDialog = new OO.ui.MessageDialog();
var windowManager = new OO.ui.WindowManager();
$('body').append(windowManager.$element);
windowManager.addWindows([messageDialog]);
$watchlistReset.submit(function(event) {
event.preventDefault();
windowManager.openWindow(messageDialog, {
title: 'Confirm',
message: 'Mark all pages as visited?',
actions: [{ action: 'reject', label: 'Cancel', flags: ['safe', 'destructive'] },
{ action: 'reset', label: 'Confirm', flags: ['primary', 'progressive']}]
}).then(function(opened) {
opened.then(function(closing, data) {
if (data && data.action === 'reset') {
new mw.Api().post({
action: 'setnotificationtimestamp',
entirewatchlist: '',
token: mw.user.tokens.get('editToken')
}).done(function() {
$('.mw-changeslist-line-watched').removeClass('mw-changeslist-line-watched').addClass('mw-changeslist-line-not-watched');
});
}
});
});
});
});