sbg-enhanced

Форк
0
/
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

19
    const UserScriptsSection = document.createElement('div')
20
    UserScriptsSection.classList.add('settings-section')
21

22
    const header = document.createElement('h4')
23
    header.classList.add('settings-section__header')
24
    header.innerText = 'User Scripts'
25
    UserScriptsSection.appendChild(header)
26

27
    const CreateScript = ({id, src}) => {
28
        const script = document.createElement('script')
29
        script.id = id
30
        script.src = src
31
        script.defer = true
32
        script.async = true
33
        script.type = 'text/javascript'
34

35
        return script
36
    }
37

38
    const CreateToggle = ({id, name, src}) => {
39
        const input = document.createElement('input')
40
        input.type = 'checkbox'
41
        input.dataset.id = id
42

43
        const title = document.createElement('span')
44
        title.innerText = name
45

46
        const label = document.createElement('label')
47
        label.classList.add('settings-section__item')
48

49
        label.appendChild(title)
50
        label.appendChild(input)
51

52
        if (localStorage.getItem(`userscript-${id}`) == 1)
53
        {
54
            const script = CreateScript({id, src})
55
            document.head.appendChild(script)
56
            input.checked = true
57
        }
58

59
        input.addEventListener('change', (event) => {
60
            localStorage.setItem(`userscript-${id}`, event.target.checked ? 1 : 0)
61
        })
62

63
        UserScriptsSection.appendChild(label)
64
    }
65

66
    [
67
        {
68
            id: 'cui',
69
            name: 'SBG Custom UI',
70
            src: 'https://nicko-v.github.io/sbg-cui/index.min.js'
71
        },
72
        {
73
            id: 'eui',
74
            name: 'SBG Enhanced UI',
75
            src: 'https://github.com/egorantonov/sbg-enhanced/releases/latest/download/index.js'
76
        },
77
    ].forEach(s => CreateToggle(s))
78

79
    const SettingSections = Array.from(document.querySelectorAll('.settings-section'))
80
    SettingSections.at(-1).after(UserScriptsSection)
81

82
})()

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.