ISCUT HELPER

Automatically extracts a domain from ISCUT pages and opens a Google site: search after a 3-second countdown.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         ISCUT HELPER
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Automatically extracts a domain from ISCUT pages and opens a Google site: search after a 3-second countdown.
// @author       Mrtznx
// @match        https://iscut.eu/i/*
// @grant        GM_openInTab
// ==/UserScript==

(function() {
    'use strict';

    // 1. Find a domain in the page text
    const text = document.body.innerText;
    const match = text.match(/site:\s*((?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,})/i);
    if (!match) return;   // nothing found

    const domain = match[1];
    const searchUrl = `https://www.google.com/search?q=site:${encodeURIComponent(domain)}`;

    // 2. Create a small notification box with countdown
    const box = document.createElement('div');
    box.style.cssText = `
        position: fixed;
        bottom: 20px;
        right: 20px;
        background: #222;
        color: #fff;
        padding: 12px 18px;
        border-radius: 8px;
        font-family: sans-serif;
        font-size: 14px;
        z-index: 9999;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        display: flex;
        align-items: center;
        gap: 12px;
        opacity: 0.9;
        border: 1px solid #555;
    `;
    box.innerHTML = `
        <span>🔍 Opening search for <strong>${domain}</strong> in <span id="timerDisplay">3</span>s</span>
        <button id="cancelTimer" style="background:#d32f2f;color:#fff;border:none;padding:4px 10px;border-radius:4px;cursor:pointer;">Cancel</button>
    `;
    document.body.appendChild(box);

    const timerSpan = document.getElementById('timerDisplay');
    const cancelBtn = document.getElementById('cancelTimer');
    let countdown = 3;
    let timerId = null;

    // 3. Countdown logic
    function startCountdown() {
        timerId = setInterval(() => {
            countdown -= 1;
            if (countdown <= 0) {
                clearInterval(timerId);
                box.remove();               // remove notification
                GM_openInTab(searchUrl, { active: false });  // open in background
            } else {
                timerSpan.textContent = countdown;
            }
        }, 1000);
    }

    // 4. Cancel button: clear timer and remove box
    cancelBtn.addEventListener('click', () => {
        clearInterval(timerId);
        box.remove();
    });

    // 5. Start the timer
    startCountdown();
})();