Hello World Overlay

Add a button that displays a "Hello World" overlay when clicked

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Hello World Overlay
// @namespace    http://your-namespace.com
// @version      1.0
// @description  Add a button that displays a "Hello World" overlay when clicked
// @match        http://*/*
// @match        https://*/*
// @grant        none
// @license    MIT
// ==/UserScript==

(function() {
    'use strict';
     const button = document.createElement('button');
           button.textContent = '按钮';
           button.style.position = 'fixed';
           button.style.bottom = '20px';
           button.style.right = '20px';
           button.style.zIndex = '9999';
    const overlay = document.createElement('div');
        overlay.style.position = 'fixed';
        overlay.style.bottom = '0';
        overlay.style.right = '0';
        overlay.style.width = '30%';
        overlay.style.height = '30%';
        overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
        overlay.style.zIndex = '99999';
        overlay.style.display = 'flex';
        overlay.style.justifyContent = 'center';
        overlay.style.alignItems = 'center';

  const text = document.createElement('span');
        text.textContent = 'Hello World';
        text.style.color = 'white';
        text.style.fontSize = '24px';
        text.style.fontWeight = 'bold';

        overlay.appendChild(text);
        document.body.appendChild(overlay);
        overlay.style.display= "none"
 const close = document.createElement('span');
        close.textContent = 'X';
        close.style.color = 'white';
        close.style.fontSize = '24px';
        close.style.fontWeight = 'bold';
        close.style.position = 'fixed';
        close.style.bottom = '25%';
        close.style.right = '1%';
        close.style. cursor= "pointer";

        overlay.appendChild(close);
        document.body.appendChild(overlay);

    // 点击按钮时显示蒙层
    button.addEventListener('click', function() {
         overlay.style.display= "block"
    });
    // 关闭
    close.addEventListener('click', function() {
         overlay.style.display= "none"
    });

    // 将按钮添加到页面中
    document.body.appendChild(button);
    // Your code here...
})();