SEO toggle

Standard Enabled Offline toggle

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        SEO toggle
// @namespace   https://greasyfork.org/users/843419
// @match       https://www.roblox.com/*
// @grant       GM_setValue
// @grant       GM_getValue
// @version     1.0
// @author      Zgoly
// @description Standard Enabled Offline toggle
// @license     MIT
// ==/UserScript==

let toggled = GM_getValue('toggled', false)

Roblox.Lang.SEO = {}

if (Roblox.ProtocolHandlerClientInterface.gameLocale == 'ru_ru') {
    Roblox.Lang.SEO.Enabled = "СВО активирован"
    Roblox.Lang.SEO.Disabled = "СВО деактивирован"
} else {
    Roblox.Lang.SEO.Enabled = "SEO activated"
    Roblox.Lang.SEO.Disabled = "SEO deactivated"
}

const customDiv = document.createElement("div")
customDiv.classList.add("custom")

const alertSystemFeedback = document.createElement("div")
alertSystemFeedback.classList.add("alert-system-feedback")

const alertSuccess = document.createElement("div")
alertSuccess.classList.add("alert", "alert-success")

const alertContent = document.createElement("span")
alertContent.classList.add("alert-content")

alertSuccess.appendChild(alertContent)
alertSystemFeedback.appendChild(alertSuccess)
customDiv.appendChild(alertSystemFeedback)

document.body.appendChild(customDiv)

function showMessage(toggled) {
    alertContent.textContent = toggled ? Roblox.Lang.SEO.Enabled : Roblox.Lang.SEO.Disabled
    alertSuccess.classList.remove("alert-success", "alert-warning")
    alertSuccess.classList.add("on", toggled ? "alert-success" : "alert-warning")
    setTimeout(function () {
        alertSuccess.classList.remove("on")
    }, 2000)
}

document.addEventListener("keydown", e => {
    if (e.code == 'KeyG') {
        fetch("https://apis.roblox.com/user-settings-api/v1/user-settings", { "credentials": "include" })
            .then(response => response.json())
            .then(data => {
                const toggled = data.whoCanJoinMeInExperiences == "Friends"
                showMessage(toggled)

                fetch("https://apis.roblox.com/user-settings-api/v1/user-settings", {
                    "headers": {
                        "content-type": "application/json;charset=UTF-8",
                        "x-csrf-token": Roblox.XsrfToken.getToken()
                    },
                    "body": JSON.stringify({ "whoCanJoinMeInExperiences": toggled ? "NoOne" : "Friends" }),
                    "method": "POST",
                    "credentials": "include"
                })
            })
    }
})