Seltani Editor Enhancer

Enhances the Seltani build page with monospace fonts and no spellcheck

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Seltani Editor Enhancer
// @namespace    https://mkps.app/
// @version      0.1.3
// @description  Enhances the Seltani build page with monospace fonts and no spellcheck
// @tag          games
// @author       MK
// @license      MIT
// @match        *://seltani.net/*
// @icon         https://mystonline.com/favicon.ico
// @grant        GM_addStyle
// ==/UserScript==

(() => {
	"use strict";

	const STYLE = `
		.BuildPropKey, .BuildPropSubpane, .BuildPropTable td:first-child:not(:last-child) a {
			font-family: Consolas, Inconsolata, "Courier New", monospace;
		}
		.BuildPropSubpane[placeholder="Code"], .BuildPropSubpane[placeholder="Value"] {
			overflow-x: visible !important;
			white-space: nowrap;
			tab-size: 4;
		}
	`;

	function main() {
		GM_addStyle(STYLE);

		for (const element of document.querySelectorAll(".BuildPropKey, .BuildPropSubpane")) {
			unsafeWindow.$(element).trigger("autosize.resize");
		}

		forMatchingElementsForever(".BuildPropKey, .BuildPropSubpane", (element) => {
			element.setAttribute("spellcheck", false);
		});
	}

	function forMatchingElementsForever(selector, fn) {
		const observer = new MutationObserver((list) => {
			for (const mutation of list) {
				for (const addedNode of mutation.addedNodes) {
					if (addedNode.nodeType !== Node.ELEMENT_NODE) {continue;}
					for (const newNode of addedNode.querySelectorAll(selector)) {
						fn(newNode);
					}
				}
			}
		});
		observer.observe(document.body, {childList: true, subtree: true});

		for (const element of document.querySelectorAll(selector)) {
			fn(element);
		}
	}

	main();
})();