Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jimmygle/caae920e4639963cbd963f135a414269 to your computer and use it in GitHub Desktop.
Save jimmygle/caae920e4639963cbd963f135a414269 to your computer and use it in GitHub Desktop.
Removes nagging upgrade banners and buttons from the awesome protonmail web client, using Tampermonkey
// ==UserScript==
// @name Hides Protonmail upgrade nagging
// @namespace github.com/jimmygle
// @version 2024-06-07
// @description Removes nagging protonmail upgrade banners/images/buttons.
// @author Jimmy Gleason
// @match https://mail.proton.me/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
// Waits for element to load in DOM
function waitForElement(selector, callback) {
const observer = new MutationObserver((mutations, observer) => {
const targetElement = document.querySelector(selector);
if (targetElement) {
callback(); // Element found, execute the callback
observer.disconnect(); // Stop observing
}
});
// Start observing the body for changes
observer.observe(document.body, { childList: true, subtree: true });
}
// Removes the nagging banner above email list to upgrade
function removeUpgradeBanner() {
console.log("Removing upgrade banner from above list of emails.");
// Perform actions on the found element
const element = document.querySelector('div[data-testid="auto-delete:banner"]');
if (element.querySelector('div > div > div').innerText == 'Upgrade to automatically delete messages that have been in trash and spam for more than 30 days.\nUpgrade') {
element.style.display = 'none'; // Hide the element
}
}
// Removes nagging button in header to upgrade
function removeUpgradeButton() {
console.log("Removing upgrade button from header navigation.");
// Perform actions on the found element
const element = document.querySelector('li[class="topnav-listItem topnav-listItem--noCollapse"]');
if (element.querySelector('button > span span').innerText == 'Upgrade') {
element.style.display = 'none'; // Hide the element
}
}
waitForElement('li[class="topnav-listItem topnav-listItem--noCollapse"]', removeUpgradeButton);
waitForElement('div[data-testid="auto-delete:banner"]', removeUpgradeBanner);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment