Created
May 23, 2021 22:49
-
-
Save mhluska/ce938a4c7d05c9748ddc7c333a5c4493 to your computer and use it in GitHub Desktop.
Tampermonkey Script - Gmail Unsubscribe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Gmail Unsubscribe | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Unsubscribe by pressing \ | |
// @author Maros Hluska | |
// @homepage https://mhluska.com | |
// @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('[role="link"]')).find(node => node.innerText === 'Unsubscribe') | |
if (!link) { | |
return; | |
} | |
link.click(); | |
Array.from(document.querySelectorAll('button')).find(node => node.innerText === 'Unsubscribe').click(); | |
} | |
(function() { | |
'use strict'; | |
document.addEventListener('keypress', unsubscribe); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment