seiya-saiga.com

-

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         seiya-saiga.com
// @version      0.0.1
// @name         -
// @description  -
// @include      https://seiya-saiga.com/game/*
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_deleteValue
// @run-at       document-end
// @namespace https://greasyfork.org/users/480818
// ==/UserScript==

const db = document.body,

    cb = db.querySelectorAll("[type=checkbox]"),

    n = /(?<=\/)\w+(?=\.html)/.exec(location.pathname)

let va = GM_getValue(""), vl

va ? (() => {
    va = JSON.parse(va)

    vl = va[n]

    vl && window.addEventListener("load", () => {
        cb.forEach((el, ei) => (el.checked = vl[ei]))
    })
})() : va = {}

window.addEventListener("click", event => {
    const ti = Array.from(cb).indexOf(event.target)

    ~ti && (() => {
        // initialize the list only when clicked
        vl || (vl = Array(cb.length).fill(0))

        vl[ti] = cb[ti].checked ? 1 : 0

        va[n] = vl

        GM_setValue("", JSON.stringify(va))
    })()
})

db.removeAttribute("oncontextmenu")
db.removeAttribute("onselectstart")

// print json
console.log(va)