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와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 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();
})();