Skip to content

Instantly share code, notes, and snippets.

@SteveHere
Last active February 2, 2024 18:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SteveHere/1a19df5242802df3edcc7d34d5c62523 to your computer and use it in GitHub Desktop.
Save SteveHere/1a19df5242802df3edcc7d34d5c62523 to your computer and use it in GitHub Desktop.
Epitaph - Add 'Hide Civ' button - Tampermonkey script
// ==UserScript==
// @name Add 'Hide Civ' Button
// @version 0.1
// @namespace https://gist.github.com/SteveHere/1a19df5242802df3edcc7d34d5c62523
// @description Injects a 'Hide Civ' button for each dead civ
// @author SteveHere
// @match https://mkremins.github.io/epitaph/
// @icon none
// @grant none
// ==/UserScript==
let hideCiv = (e) => { e.target.parentElement.style = "display: none;"; };
let makeButton = () => {
let b = document.createElement('button');
b.innerText = "Hide Civ";
b.onclick = hideCiv;
return b;
};
window.buttonInjector = setInterval(function() {
[...document.getElementsByClassName('extinct')].filter(
el => el.getElementsByTagName('button').length === 0
).forEach(el => {
el.insertBefore(makeButton(), el.children[0]);
});
}, 2000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment