Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
2b32b746ac |
@ -1,53 +0,0 @@
|
||||
// ==UserScript==
|
||||
// @name Runcity Questionary
|
||||
// @namespace http://tampermonkey.net/
|
||||
// @version 2024-11-18
|
||||
// @description Add red border for empty inputs
|
||||
// @author You
|
||||
// @match https://www.runcity.org/ru/events/*/online/
|
||||
// @icon https://www.google.com/s2/favicons?sz=64&domain=runcity.org
|
||||
// @grant none
|
||||
// ==/UserScript==
|
||||
|
||||
(function () {
|
||||
'use strict'
|
||||
|
||||
/* COPY FROM MAIN */
|
||||
|
||||
function addStylesToHead(styles) {
|
||||
let styleSheet = document.createElement("style")
|
||||
styleSheet.textContent = styles
|
||||
document.head.append(styleSheet)
|
||||
}
|
||||
|
||||
/* END COPY FROM MAIN */
|
||||
|
||||
function addClassIfEmptyInput(input) {
|
||||
if (input.value.trim() == "") {
|
||||
input.classList.add("empty-input")
|
||||
}
|
||||
else {
|
||||
input.classList.remove("empty-input")
|
||||
}
|
||||
}
|
||||
|
||||
function addEmptyInputCheck() {
|
||||
let inputs = [...document.querySelectorAll(`input.cp_team_answer`)]
|
||||
|
||||
for (const input of inputs) {
|
||||
addClassIfEmptyInput(input)
|
||||
|
||||
input.addEventListener("input", e => {
|
||||
addClassIfEmptyInput(input)
|
||||
})
|
||||
}
|
||||
|
||||
addStylesToHead(`
|
||||
.empty-input {
|
||||
border-color: red !important;
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
addEmptyInputCheck()
|
||||
})();
|
Loading…
Reference in New Issue
Block a user