Blackout and Open Tab (prototype)

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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
    });
})();