Apply on page load instead of looping

This commit is contained in:
Egor Guslyancev 2024-04-10 08:07:40 -03:00
parent 8bbadd1b9e
commit 90b2c3110c
GPG Key ID: D7E709AA465A55F9
1 changed files with 10 additions and 14 deletions

24
user.js
View File

@ -13,22 +13,18 @@
// @run-at document-start
// ==/UserScript==
var success = false;
var intervalId = window.setInterval(actionFunction, 1000);
window.addEventListener('load', actionFunction);
function actionFunction() {
if (!success) {
var boxes = document.getElementsByTagName('input');
for (var i = 0; i < boxes.length; i++) {
if (boxes[i].type === 'checkbox' | boxes[i].type === 'radio') {
var span = document.createElement('span');
span.innerHTML =
boxes[i].type === 'radio' && boxes[i].value == "1"
? "<b>" + boxes[i].value + "</b>"
: boxes[i].value;
boxes[i].parentNode.insertBefore(span, boxes[i].parentNode.children[0]);
success = true;
}
var boxes = document.getElementsByTagName('input');
for (var i = 0; i < boxes.length; i++) {
if (boxes[i].type === 'checkbox' | boxes[i].type === 'radio') {
var span = document.createElement('span');
span.innerHTML =
boxes[i].type === 'radio' && boxes[i].value == "1"
? "<b>" + boxes[i].value + "</b>"
: boxes[i].value;
boxes[i].parentNode.insertBefore(span, boxes[i].parentNode.children[0]);
}
}
}