Skip to content

Instantly share code, notes, and snippets.

@madox2
Created April 25, 2020 18:25
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 madox2/2d165dc1285cc5fd7e71b0011a316123 to your computer and use it in GitHub Desktop.
Save madox2/2d165dc1285cc5fd7e71b0011a316123 to your computer and use it in GitHub Desktop.
Enables auto-end turn for KDice
// ==UserScript==
// @name KDice Auto-end turn
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Auto-end turn for KDice
// @author You
// @match https://kdice.com/*
// @grant none
// ==/UserScript==
(function() {
function showAutoEndTurn() {
var xpath = "//label[text()='Auto end turn']";
var label = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
if (label) {
label.parentElement.style.margin = '0px 10px'
label.parentElement.style.display = 'block'
}
}
function init() {
const controls = document.querySelector('.iogc-Controls')
if (!controls) {
// wait for dom to load
setTimeout(init, 1000)
return
}
const observer = new MutationObserver(showAutoEndTurn)
const config = { attributes: true, childList: true, subtree: true }
observer.observe(controls, config)
showAutoEndTurn()
}
init()
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment