Created
November 16, 2022 18:13
-
-
Save max-kamps/efa050f059264b36e2b3aacda58ea8be to your computer and use it in GitHub Desktop.
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 Review Countdown | |
// @namespace Violentmonkey Scripts | |
// @match https://jpdb.io/review | |
// @grant none | |
// @version 2.0 | |
// @author hmry | |
// @description 5/7/2022, 10:07:03 PM | |
// ==/UserScript== | |
let SECONDS = 6; | |
let AUTOREVEAL = false; | |
// Code starts here | |
const kindTextElem = document.querySelector('.kind'); | |
if (kindTextElem) { | |
kindTextElem.insertAdjacentHTML('beforebegin', ` | |
<div class="countdown" style="font-size: 200%; text-align: center;">${SECONDS}</div> | |
`); | |
const countdown = document.querySelector('.countdown'); | |
const interval = setInterval(() => { | |
SECONDS -= 1; | |
if (!countdown.classList.contains('countdown')) { | |
// Our element was removed - the user answered? | |
clearInterval(interval); | |
} else if (SECONDS <= 0) { | |
clearInterval(interval); | |
countdown.innerText = `!! ${SECONDS} !!`; | |
countdown.style.color = 'red'; | |
if (AUTOREVEAL) | |
document.querySelector('form[action="/review#a"]').submit(); | |
} else { | |
countdown.innerText = `${SECONDS}`; | |
} | |
}, 1000) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment