Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Userscript: Fallen London - Discard All
// ==UserScript==
// @name Fallen London - Discard All
// @namespace http://shadenexus.com
// @version 1.2
// @description Discard all discardable cards
// @author Gwyndolyn Marchant
// @match https://www.fallenlondon.com/
// @icon https://www.google.com/s2/favicons?domain=fallenlondon.com
// @grant none
// ==/UserScript==
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
(async function() {
'use strict';
const selector = ".card__discard-button:not(.button--disabled)";
let e = document.createElement("button");
e.innerHTML = "Discard<br/>All ♻";
e.id = "discard-all-button";
e.className = "button button--primary button--small";
e.style.position = "absolute";
e.style.zIndex = "10";
e.style.height = "auto";
e.style.left = "0px";
e.style.top = "5px";
e.addEventListener("click", async () => {
let disc = document.querySelector(selector);
while (disc != null) {
disc.click();
await sleep(10);
disc = document.querySelector(selector);
}
});
let cards = null;
setInterval(function(){
if (document.getElementById("discard-all-button") == null) {
cards = document.querySelector("div.cards");
cards.prepend(e);
}
}, 5000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment