Last active
August 31, 2026 06:24
-
-
Save Daeloth/fb25c8a73f849210ef8232fabe6e2b54 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 YNO UI component lib | |
| // @version 1.0.0 | |
| // | |
| // @match https://ynoproject.net/2kki/* | |
| // @grant unsafeWindow | |
| // @author Daeloth | |
| // @description | |
| // ==/UserScript== | |
| (()=>{ | |
| if (unsafeWindow.ynoComponents) return; | |
| unsafeWindow.ynoComponents = { | |
| newModal, | |
| newTitle, | |
| newButton, | |
| newOptionLabel, | |
| newOptionToggle, | |
| newOptionNumber, | |
| newOptionCheckboxButton, | |
| newOptionNumberInput, | |
| } | |
| function newModal(data) { | |
| const modal = document.createElement("div"); | |
| modal.className = "modal"; | |
| if (data.id) { | |
| modal.id = data.id; | |
| } | |
| if (data.title) { | |
| const title = newTitle({ | |
| text: data.title | |
| }); | |
| modal.appendChild(title); | |
| } | |
| document.getElementById("modalContainer").appendChild(modal); | |
| const content = document.createElement("div"); | |
| modal.appendChild(content); | |
| content.className = "modalContent"; | |
| return modal; | |
| } | |
| function newTitle(data) { | |
| const title = document.createElement("div"); | |
| title.className = "modalTitle"; | |
| title.innerText = data.text; | |
| return title; | |
| } | |
| function newButton(data){ | |
| const button = document.createElement("button"); | |
| button.className = "unselectable"; | |
| button.type = "button"; | |
| if (data.id) { | |
| button.id = data.id; | |
| } | |
| if (data.onclick) { | |
| button.onclick = data.onclick; | |
| } | |
| if (data.name) { | |
| button.innerText = data.name; | |
| } else { | |
| button.innerText = "Button"; | |
| } | |
| return button; | |
| } | |
| function newOptionLabel(data){ | |
| var label = document.createElement("label"); | |
| label.className = "unselectable"; | |
| label.innerText = data.name; | |
| return label; | |
| } | |
| function newOptionToggle(data) { | |
| var formControlRow = document.createElement("li"); | |
| formControlRow.className = "formControlRow"; | |
| formControlRow.dataset["id"] = data.id; | |
| var label = newOptionLabel({ | |
| name: data.name | |
| }); | |
| formControlRow.appendChild(label); | |
| var div = document.createElement("div"); | |
| formControlRow.appendChild(div); | |
| var button = newOptionCheckboxButton({ | |
| id: data.id.replace(".", "-"), | |
| default: data.default, | |
| onclick: data.onclick, | |
| }); | |
| div.appendChild(button); | |
| return formControlRow; | |
| } | |
| function newOptionNumber(data) { | |
| var formControlRow = document.createElement("li"); | |
| formControlRow.className = "formControlRow"; | |
| formControlRow.dataset["id"] = data.id; | |
| var label = newOptionLabel({ | |
| name: data.name | |
| }); | |
| formControlRow.appendChild(label); | |
| var div = document.createElement("div"); | |
| formControlRow.appendChild(div); | |
| var input = newOptionNumberInput({ | |
| id: data.id.replace(".", "-"), | |
| default: data.default, | |
| onchange: data.onclick, | |
| }); | |
| div.appendChild(input); | |
| return formControlRow; | |
| } | |
| function newOptionCheckboxButton(data) { | |
| var button = document.createElement("button"); | |
| var span = document.createElement("span") | |
| button.appendChild(span); | |
| button.id = data.id; | |
| button.className = "checkboxButton unselectable"; | |
| button.classList.toggle("toggled", data.default); | |
| if (data.onclick) { | |
| button.onclick = data.onclick; | |
| } | |
| return button; | |
| } | |
| function newOptionNumberInput(data) { | |
| var input = document.createElement("input"); | |
| var span = document.createElement("span") | |
| input.appendChild(span); | |
| input.id = data.id; | |
| input.className = "unselectable"; | |
| if (data.onchange) { | |
| button.onchange = data.onchange; | |
| } | |
| return button; | |
| } | |
| })() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment