sbg-enhanced
/
remote.js
82 строки · 2.6 Кб
1// ==UserScript==
2// @name SBG User Script Remote Loader
3// @namespace https://3d.sytes.net/
4// @version 3.0.0
5// @downloadURL https://github.com/egorantonov/sbg-enhanced/releases/latest/download/remote.js
6// @updateURL https://github.com/egorantonov/sbg-enhanced/releases/latest/download/remote.js
7// @description Remote loader for SBG Enhanced UI
8// @author https://github.com/egorantonov
9// @website https://github.com/egorantonov/sbg-enhanced/releases
10// @match https://3d.sytes.net
11// @match https://3d.sytes.net/*
12// @iconUrl https://i.imgur.com/ZCPXYQA.png
13// @icon64Url https://i.imgur.com/ZCPXYQA.png
14// @grant none
15// ==/UserScript==
16
17(function() {18
19const UserScriptsSection = document.createElement('div')20UserScriptsSection.classList.add('settings-section')21
22const header = document.createElement('h4')23header.classList.add('settings-section__header')24header.innerText = 'User Scripts'25UserScriptsSection.appendChild(header)26
27const CreateScript = ({id, src}) => {28const script = document.createElement('script')29script.id = id30script.src = src31script.defer = true32script.async = true33script.type = 'text/javascript'34
35return script36}37
38const CreateToggle = ({id, name, src}) => {39const input = document.createElement('input')40input.type = 'checkbox'41input.dataset.id = id42
43const title = document.createElement('span')44title.innerText = name45
46const label = document.createElement('label')47label.classList.add('settings-section__item')48
49label.appendChild(title)50label.appendChild(input)51
52if (localStorage.getItem(`userscript-${id}`) == 1)53{54const script = CreateScript({id, src})55document.head.appendChild(script)56input.checked = true57}58
59input.addEventListener('change', (event) => {60localStorage.setItem(`userscript-${id}`, event.target.checked ? 1 : 0)61})62
63UserScriptsSection.appendChild(label)64}65
66[67{68id: 'cui',69name: 'SBG Custom UI',70src: 'https://nicko-v.github.io/sbg-cui/index.min.js'71},72{73id: 'eui',74name: 'SBG Enhanced UI',75src: 'https://github.com/egorantonov/sbg-enhanced/releases/latest/download/index.js'76},77].forEach(s => CreateToggle(s))78
79const SettingSections = Array.from(document.querySelectorAll('.settings-section'))80SettingSections.at(-1).after(UserScriptsSection)81
82})()