Skip to content

Instantly share code, notes, and snippets.

@mhluska
Created May 23, 2021 22:49
Show Gist options
  • Save mhluska/ce938a4c7d05c9748ddc7c333a5c4493 to your computer and use it in GitHub Desktop.
Save mhluska/ce938a4c7d05c9748ddc7c333a5c4493 to your computer and use it in GitHub Desktop.
Tampermonkey Script - Gmail Unsubscribe
// ==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