-
-
Save GwyndolynMarchant/17b644c90f0184a50a226fecb715949c to your computer and use it in GitHub Desktop.
Userscript: Fallen London - Discard All
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 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