Jump to content

User:TheDJ/deleteWatchlistModifications.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.
// loaded when document.ready.. will possibly have to run several times, due to async stylesheet loading
function deleteWatchlistModifications() {
	var removeRules = [];
	var styleSheet, styleSheets = document.styleSheets;
	var rule, rules;
	try {
		for (var i=0; i < styleSheets.length; i++) {
			removeRules = [];
			styleSheet = styleSheets[i];
			rules = styleSheet.rules;
			if (
				styleSheet.href && styleSheet.href.indexOf( 'WatchlistBase') !== -1
				&& styleSheet.href.indexOf( 'WatchlistGreenIndicators') !== -1
				&& styleSheet.href.indexOf( 'WatchlistChangesBold') !== -1
			) {
				continue;
			}
			for ( var j=0; j < rules.length; j++ ) {
				rule = rules[j];
				if( rule.type !== rule.STYLE_RULE ) {
					continue;
				}
				switch (rule.selectorText) {
					// WatchlistBase
					case '#mw-wlheader-showupdated, #mw-wlheader-bold, #mw-wlheader-green, #mw-watchlist-resetbutton':
					case '.mw-special-Watchlist .mw-changeslist-line-watched .mw-title, .mw-enhanced-watched .mw-enhanced-rc-time':
					// WatchlistGreenIndicators(Mono)
					case '#mw-wlheader-showupdated, #mw-wlheader-green':
					case '#mw-watchlist-resetbutton':
					case 'li.mw-changeslist-line-watched, li.mw-history-line-updated':
					case 'td.mw-enhanced-rc, .mw-enhanced-rc-time':
					case '.mw-enhanced-rc-nested':
					case '.mw-enhancedchanges-arrow-space':
					case '.mw-enhanced-rc-nested, .mw-enhancedchanges-arrow-space':
					case '.mw-enhanced-watched .mw-enhanced-rc-nested, .mw-changeslist-line-watched .mw-enhancedchanges-arrow-space':
					case '.mw-changeslist-line-not-watched .mw-collapsible-arrow.mw-collapsible-toggle-collapsed':
					case '.mw-changeslist-line-not-watched .mw-collapsible-arrow.mw-collapsible-toggle-expanded':
					case '.mw-changeslist-line-watched .mw-collapsible-arrow.mw-collapsible-toggle-collapsed':
					case '.mw-changeslist-line-watched .mw-collapsible-arrow.mw-collapsible-toggle-expanded':
					// WatchlistChangesBold
					case '#mw-wlheader-green':
					case '#mw-wlheader-showupdate, #mw-wlheader-bold':
					case '#mw-watchlist-resetbutton':
					case '.mw-special-Watchlist .mw-changeslist-line-watched .mw-title':
						removeRules.push(rule);
						break;
					default:
						break;
				}
			}
			console.log( 'Removing ' + removeRules.length + ' rules from stylesheet ' + i);
			for( j=0; j<removeRules.length; j++) {
				styleSheet.removeRule( removeRules[j]);	
			}
		}
	} catch (e) {
		// ignore any and all errors
	}
}
$( deleteWatchlistModifications );