User:Ahecht/Scripts/watchlistcleaner

A userscript to remove missing pages (redlinks), redirects, pages you haven't edited recently, and/or pages you've never edited from your watchlist. The script will prompt to ask which types of pages you want to remove, and how many days of history it should look at, and whether it should skip removing any pages you created. The script can optionally store a backup of the pages it removes at Special:MyPage/Watchlist_backup, which can be used with the Special:RecentChangesLinked tool.

Usage
When you're on your watchlist, click on the " Clean the watchlist " link on the top toolbar (next to the " Clear the watchlist " link). On some skins, this link may appear in the "Toolbox" or "Tools" menu instead.

The script will prompt you with the following questions:


 * Remove redlinked (missing) pages from Watchlist? — Removes any pages from your watchlist that no longer exist
 * Skip removing redlinked pages if talk page exists? — Doesn't remove pages where the talk page exists (this is common with the talk pages of new users or IP editors)
 * Remove redirects from Watchlist? — Removes pages from your watchlist that are redirects. It does not remove the redirect targets.
 * Remove pages from Watchlist you haven't recently edited (slow)? — Removes any pages from your watchlist where you haven't made a recent edit to either the page or its talk page.
 * Minimum number of days since your last edit: — Specifies the maximum number of days for an edit to be considered recent.
 * Remove pages from Watchlist you have never edited (slow)? — Removes any pages from your watchlist where you haven't ever made an edit to either the page or its talk page.
 * Skip removing pages you created (slow)? — Don't remove any pages from your watchlist where you made the initial edit to that page. This won't work for pages you created that have since been deleted, but works for redirects and pages that you haven't edited recently.

The script will then fetch items from your watchlist in batches of 500, which is relatively fast, and show any missing pages or redirects that it identifies as potential pages for removal. If you selected the option to find pages you haven't edited recently or pages you never edited, it will look at the remaining pages on your watchlist, one at a time, and examine their revision histories -- this can take a long time on large watchlists. Finally, if you've selected the option to skip removing pages you created, it will examine all pages flagged for removal to see if you made the first edit -- this can be slow if you're removing a large number of pages at once.

Once the script has finished examining pages on your watchlist, it will notify you of how many pages it found to remove, an ask the following questions:


 * Remove ### pages from watchlist? — Proceeds with removal. Hit "Cancel" to exit without modifying your watchlist
 * Backup removed pages? — Backs up all removed pages to Special:MyPage/Watchlist_backup

If you don't hit "Cancel" on the first question it will then process the removals in batches of 50 and notify you of the result. If you selected the backup option, it will also display a message showing where the backup was saved.

If you want more details on the script's progress as its running, you can open your browser's debug console (Help:CONSOLE).