Created
May 7, 2024 13:57
-
-
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
This file contains hidden or 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 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