Skip to content

Instantly share code, notes, and snippets.

@AndersMoberg
Last active March 22, 2024 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndersMoberg/cd7ed41d10381a16718d3e9fcc714001 to your computer and use it in GitHub Desktop.
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.
// ==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