Vjudge背景替换

将Vjudge的背景图片更改为必应的每日一图

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Vjudge背景替换
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  将Vjudge的背景图片更改为必应的每日一图
// @author       LLDQ
// @match        https://vjudge.net/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 设置背景图片的URL
    const backgroundImageUrl = 'https://bing.img.run/uhd.php';

    // 创建一个样式元素
    const style = document.createElement('style');
    style.type = 'text/css';

    // 设置背景图片样式
    style.innerHTML = `
        body {
            background-image: url('${backgroundImageUrl}') !important;
            background-size: cover !important;
            background-position: center !important;
            background-repeat: no-repeat !important;
            background-attachment: fixed !important; /* 固定背景图片 */
        }

        /* 添加半透明遮罩层 */
        body::before {
            content: '';
            position: fixed; /* 固定遮罩层 */
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(255, 255, 255, 0.4); /* 白色半透明遮罩 */
            z-index: -1; /* 将遮罩层置于背景图片之上,但位于内容之下 */
        }

     `;

    // 将样式元素添加到文档的head中
    document.head.appendChild(style);
})();