MediaWiki:AjaxThreadUnfollow/code.js

/* * Ajax Unfollow * Allows to quickly unfollow threads directly from your notifications * Personal use only * @author Dorumin (w:c:dev:AjaxThreadUnfollow) */ (function($, mw, AjaxThreadUnfollow) { var AjaxThreadUnfollowLang = {    // English    en: {      title: 'Shift + Click to quickly unfollow',      unfollowed: 'The thread has been unwatched.'    },    // Español    es: {      title: 'Shift + Click para dejar de seguir',      unfollowText: 'Has dejado de seguir al hilo.'    }  };  var lang = mw.config.get('wgUserLanguage');  if (AjaxThreadUnfollowLang[lang] === undefined) {    lang = 'en';  }  var noRepeatNotifUpdate = false;  $('#GlobalNavigationWallNotifications').bind('DOMSubtreeModified', function { if (!noRepeatNotifUpdate) { noRepeatNotifUpdate = true; setTimeout(function {       $('.notification').each(function { var notifs = $("#notificationsContainer").find('.notification'); notifs.each(function {           $(this).attr('title', AjaxThreadUnfollowLang[lang].title);            $(this).click(function(event) { if (event.shiftKey) { event.preventDefault; var li = $(this); var target = $(this).children('a').attr('href').split('/wiki/')[1].split('#')[0]; var api = new mw.Api; api.unwatch(target, $.noop).done(function {                 li.replaceWith(' ' + AjaxThreadUnfollowLang[lang].title + ' '); // The old notification will go back after a few seconds, its supposed to be that way*                }); }           });          });        });      }, 1500);      setTimeout(function {        noRepeatNotifUpdate = false;      }, 3000); } }); })(this.jQuery, this.mediaWiki, window.AjaxThreadUnfollow); // *can't figure a way to easily stop it