luogu-background-css-loader

洛谷主题背景修改

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         luogu-background-css-loader
// @namespace    luogu-background-css-loader
// @version      1.0
// @description  洛谷主题背景修改
// @author       Zhetengtiao
// @match        *://www.luogu.com.cn/*
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_registerMenuCommand
// ==/UserScript==

function payload()
{
    var css = GM_getValue("css");
    document.querySelector('main[style="background-color: rgb(239, 239, 239);"]').style=css;//新版原生方法
}
window.onload=function(){
    var config = GM_getValue("config");
    if(GM_getValue("config")==null) {
        config=1
        alert("感谢使用!第一次运行请打开Tampermonkey菜单,点击“设置背景CSS”以设置背景CSS");
        GM_setValue("config",config);
        GM_setValue("css","background-color: rgb(239, 239, 239);");
    }
    GM_registerMenuCommand("设置背景CSS",function(){
        var css = GM_getValue("css");
        css=prompt("设置背景CSS:","");
        GM_setValue("css",css);
        alert("设置成功!请刷新页面");
    });
    payload();//页面加载完毕运行一次
    setTimeout(function(){
        payload();
    }, 2000);//运行后2秒后再运行一次
};