Jump to content

User:ToBeFree/scripts/clear-watchlist.js

From Wikipedia, the free encyclopedia
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.
/* Clear your entire watchlist over time: Remove the first 500 entries each time you open any Wikipedia page.
 * This script will work even if the watchlist is too full to be edited or cleared by conventional methods.
 * built using: https://en.wikipedia.org/w/index.php?title=Help:Customizing_toolbars&oldid=982882848, https://www.mediawiki.org/w/index.php?title=API:Watch&oldid=4112591#Sample_code
 */

$.when( mw.loader.using('mediawiki.util'), $.ready ).then( function() {
  var params = { action: 'watch', unwatch: 'true', generator: 'watchlistraw', gwrlimit: '500', gwrnamespace:'*',   format: 'json'  },  api = new mw.Api(); api.postWithToken( 'watch', params ).done( function ( data ) {  console.log( data ); } );
} );