ISCUT HELPER

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

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