User:Weeklyd3/scripts/resetwatchlist.js

const button = document.createElement('a'); button.href = 'javascript:;'; button.textContent = 'Clear watchlist notification flags'; button.addEventListener('click', function {	this.textContent = 'Getting watchlist';	clearWatchlistNotifFlags.bind(this); }); const li = document.createElement('li'); li.setAttribute('class', "mw-list-item"); li.appendChild(button); document.querySelector('#p-personal').children[1].children[0].appendChild(li); function clearWatchlistNotifFlags(c = null) { const cont = c ? `&wrcontinue=${c}` : ""; fetch(`${mw.config.values['wgScriptPath']}/api.php?action=query&format=json&list=watchlistraw&wrlimit=500${cont}`) .then((res) => res.json) .then((function(res) { res.watchlistraw.forEach((function(title) { fetch(`${mw.config.values.wgScriptPath}/index.php?title=${encodeURIComponent(title.title)}`, {credentials: 'include'}); }).bind(this)); if (res.continue.wrcontinue) clearWatchlistNotifFlags(res.continue.wrcontinue); else { this.textContent = 'Watchlist notification flags cleared'; setTimeout( => this.textContent = 'Clear watchlist notification flags', 1000); }	}).bind(this)); }