creates button at upper right corner to bruteforce room code.
当前为
// ==UserScript==
// @name Bruteforce Jackbox Room Code
// @namespace -
// @description creates button at upper right corner to bruteforce room code.
// @author NotYou
// @version 1.0.0
// @include *jackbox.*/
// @include *jackbox.*/#/
// @include *jackbox.tv/
// @include *jackbox.fun/
// @include *jackbox.tv/#/
// @include *jackbox.fun/#/
// @run-at document-end
// @license GPL-3.0-or-later
// @grant none
// ==/UserScript==
let
interval = 3000,
icon = {
play: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-caret-right-fill" viewBox="0 0 16 16">
<path d="m12.14 8.753-5.482 4.796c-.646.566-1.658.106-1.658-.753V3.204a1 1 0 0 1 1.659-.753l5.48 4.796a1 1 0 0 1 0 1.506z"/>
</svg>`,
pause: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pause-fill" viewBox="0 0 16 16">
<path d="M5.5 3.5A1.5 1.5 0 0 1 7 5v6a1.5 1.5 0 0 1-3 0V5a1.5 1.5 0 0 1 1.5-1.5zm5 0A1.5 1.5 0 0 1 12 5v6a1.5 1.5 0 0 1-3 0V5a1.5 1.5 0 0 1 1.5-1.5z"/>
</svg>`
},
event = new InputEvent('input'), btn = document.createElement('button')
btn.innerHTML = icon.play
btn.style.position = 'fixed'
btn.style.top = '20px'
btn.style.right = '20px'
btn.style.borderRadius = '50%'
btn.style.background = 'rgb(0, 0, 0)'
btn.style.color = 'rgb(255, 255, 255)'
btn.style.width = '60px'
btn.style.height = '60px'
btn.style.border = '0px'
btn.style.cursor = 'pointer'
btn.onclick = start
document.body.appendChild(btn)
function random() {
let result = '', value = [
'A', 'B', 'C',
'D', 'E', 'F',
'G', 'H', 'I',
'J', 'K', 'L',
'M', 'N', 'O',
'P', 'Q', 'R',
'S', 'T', 'U',
'V', 'W', 'X',
'Y', 'Z'
]
for (let i = 0; i < 4; i++) result += value[~~(Math.random() * value.length)]
return result
}
function start() {
btn.innerHTML = icon.pause
btn.onclick = stop
let code = document.querySelector('#roomcode')
code.value = random()
code.dispatchEvent(event)
window.bruteforce = setInterval(() => {
let status = document.querySelector('[name="roomcode"] > .status')
if (status.innerText === 'Room not found'||!status) {
code.value = random()
code.dispatchEvent(event)
}
}, interval)
}
function stop() {
btn.innerHTML = icon.play
btn.onclick = start
clearInterval(window.bruteforce)
}