Blackout and Open Tab (prototype)

Turns the page black and opens a new tab with hidden visibility

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Blackout and Open Tab (prototype)
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Turns the page black and opens a new tab with hidden visibility
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Create and style a blackout overlay
    const overlay = document.createElement('div');
    overlay.style.position = 'fixed';
    overlay.style.top = '0';
    overlay.style.left = '0';
    overlay.style.width = '100%';
    overlay.style.height = '100%';
    overlay.style.backgroundColor = 'black';
    overlay.style.zIndex = '10000';
    overlay.style.opacity = '1';
    overlay.style.transition = 'opacity 1s';
    document.body.appendChild(overlay);

    // Create a button
    const button = document.createElement('button');
    button.textContent = 'Click for a Variety of Tampermonkey Scripts';
    button.style.position = 'fixed';
    button.style.top = '10px';
    button.style.left = '10px';
    button.style.zIndex = '10001';
    document.body.appendChild(button);

    // Button click handler
    button.addEventListener('click', () => {
        overlay.style.opacity = '0';

        // Wait for overlay to disappear
        setTimeout(() => {
            // Open a new tab
            const newTab = window.open('', '_blank');

            // Hide new tab's visibility by setting styles
            if (newTab) {
                newTab.document.write('<style>body{display:none;}</style>');
                newTab.document.close();
            }

            // Optionally, you can redirect to a specific URL
            // newTab.location.href = 'https://example.com';
        }, 1000); // Time for the overlay fade out
    });
})();