Gmail Unsubscribe Github issues

Unsubscribe by pressing \

Från och med 2023-12-22. Se den senaste versionen.

// ==UserScript==
// @name         Gmail Unsubscribe Github issues
// @namespace    http://tampermonkey.net/
// @version      0.1.2
// @license      MIT
// @description  Unsubscribe by pressing \
// @match        https://mail.google.com/*
// @icon         https://www.google.com/s2/favicons?domain=tampermonkey.net
// @grant        none
// ==/UserScript==

function unsubscribe(event) {
    if (event.key !== "\\") {
        return;
    }

    const link = Array.from(document.querySelectorAll('a[href^="https://github.com/notifications/unsubscribe-auth/"]')).find(node => node.innerText === 'unsubscribe');
    if (!link) {
      return;
    }
    link[0].click();
}

(function() {
    'use strict';

    document.addEventListener('keypress', unsubscribe);
})();