Jump to content

User:Danski454/unwatch.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Danski454 (talk | contribs) at 18:00, 1 April 2019 (see if this works). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
/*
 * Based off Unwatch from watchlist
 * @source https://www.mediawiki.org/wiki/Snippets/Unwatch_from_watchlist
 * @author Krinkle
 * @revision 2016-09-01
*/
$(document).ready(function(){
	if ( mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'Watchlist' || location.href.indexOf( '/edit' ) > 0 || location.href.indexOf( '/raw' ) > 0 ) {
		return;
	}
	mw.hook( 'wikipage.content' ).add(function(){
		$(".mw-changeslist-line-inner").each(function(){
			var line = $(this);
			if (line.find(".unwatch-link").length) {
				return false;//do not add infinite links, end loop for speed
			}
			var href = line.find(".mw-changeslist-history").attr("href");
			if (href) {
				href = href .replace("action=history", "action=unwatch");
				line.append(' <span class="unwatch-link">[<a href="' + href + '">unwatch</a>]</span>');
			}
		});
	});
});