User:Dixtosa/unwatch.js
Jump to navigation
Jump to search
Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.
- Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
- Konqueror and Chrome: click Reload or press F5;
- Opera: clear the cache in Tools → Preferences;
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.
- This script lacks a documentation subpage. Please create it.
- Useful links: root page • root page’s subpages • links • redirects • your own
// 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 ` | <a href='javascript: unwatchjs_u("${escapedTitle}")'>unwatch</a>`;
});
});
});
}