User:Dixtosa/unwatch.js

// adds unwatch button between "diff" and "hist" // Dependency: ES6 // DEPRECATED. superseded by mediawiki's own option here - Preferences/Watchlist -> Advanced options

function unwatchjs_u(Title) {	let title = decodeURIComponent(Title); new mw.Api.unwatch(title).done (function( data ) {		if ( data && data.title == title) {			$(`.mw-changeslist li .mw-title:contains('${title.replace("'", "\\'")}')`).parent.hide("slow");		} else {			mw.notify( 'The edit query returned an error.' + JSON.stringify(data) );		}	}) .fail ( function {		mw.notify( 'The ajax request failed.' );	}); }

if (mw.config.values.wgCanonicalSpecialPageName == 'Watchlist' && mw.config.values.wgAction == 'view' ) {	mw.loader.using(['mediawiki.api'], function {		$( => { $("a:contains('diff')").after(function(index) {				//I'm vegetarian				let escapedTitle = this.title.replace("'", "%27");				return ` | unwatch`;			}); });	}); }