Skip to content

Instantly share code, notes, and snippets.

@attie
Last active June 7, 2024 12:27
Show Gist options
  • Save attie/9594a7fc4537137cfa068a3cc53d5ce5 to your computer and use it in GitHub Desktop.
Save attie/9594a7fc4537137cfa068a3cc53d5ce5 to your computer and use it in GitHub Desktop.
Hide "Add to Drive" button for Gmail attachments
// ==UserScript==
// @name Hide annoying buttons on Gmail attachments
// @namespace http://attie.co.uk/
// @source https://gist.github.com/attie/9594a7fc4537137cfa068a3cc53d5ce5
// @version 2024-04-30
// @description Just get rid of the annoying buttons - https://chaos.social/@attie/112360057673910473
// @author Attie Grande <attie@attie.co.uk>
// @match https://mail.google.com/mail/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
const badButtons = [ 'Add to Drive', 'Edit with Google Docs', 'Save a copy to Photos', 'Organise in Drive' ];
function filterButtons(el) {
const n = Array.from(el.parentElement.querySelectorAll('div'))
.filter((el) => el.getAttribute('role') === 'tooltip')
.map((el) => el.innerHTML)
.filter((txt) => badButtons.includes(txt))
.length;
return n > 0;
}
setInterval(() => {
Array.from(document.querySelectorAll('div.aQw > span > button'))
.filter(filterButtons)
.forEach((el) => { el.style.display = 'none' });
}, 250);
})();
@ahornero
Copy link

ahornero commented Jun 7, 2024

@attie I don't know if the US English variation has another definition for that wording. For me (the UK one), it works like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment