Last active
March 22, 2024 19:38
-
-
Save AndersMoberg/cd7ed41d10381a16718d3e9fcc714001 to your computer and use it in GitHub Desktop.
Userscript, which adds the ability to mass-disable all email notifications on Patreon.
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 Patreon mass email-settings toggle | |
// @name Adds button to mass-change mail notifications on Patreon | |
// @version 1 | |
// @author Anders O.H Moberg | |
// @homepageURL https://a-moberg.com/ | |
// @grant none | |
// @match https://www.patreon.com/settings/email | |
// @updateURL https://gist.github.com/AndersMoberg/cd7ed41d10381a16718d3e9fcc714001/raw/patreonemail.user.js | |
// @downloadURL https://gist.github.com/AndersMoberg/cd7ed41d10381a16718d3e9fcc714001/raw/patreonemail.user.js | |
// ==/UserScript== | |
const waitFor = (delay) => new Promise((resolve) => setTimeout(resolve, delay)); | |
const delayMs = 1000; | |
let header = document.querySelector("header"); | |
let disableButton = document.createElement("button"); | |
disableButton.innerText = "Disable all"; | |
disableButton.onclick = async () => { | |
const result = document.querySelectorAll("button[aria-checked=true]"); | |
for (const button of result) { | |
button.scrollIntoView(); | |
button.dispatchEvent( | |
new MouseEvent("click", { | |
view: window, | |
bubbles: true, | |
cancelable: true, | |
buttons: 1, | |
}) | |
); | |
await waitFor(delayMs); | |
} | |
}; | |
header.appendChild(disableButton); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment