Scratch Tactical Nuke Prank

Prank script for Scratch when clicking the green flag

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Scratch Tactical Nuke Prank
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Prank script for Scratch when clicking the green flag
// @author       You
// @match        *://scratch.mit.edu/projects/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function playSound() {
        let audio = new Audio("https://www.myinstants.com/media/sounds/tactical-nuke.mp3");
        audio.play();
    }

    function spamImage() {
        let spamInterval = setInterval(() => {
            let img = document.createElement("img");
            img.src = "https://i.ibb.co/Xf4PMVD6/IMG-1365.jpg";
            img.style.position = "fixed";
            img.style.left = Math.random() * window.innerWidth + "px";
            img.style.top = Math.random() * window.innerHeight + "px";
            img.style.width = "150px";
            img.style.height = "150px";
            img.style.zIndex = "9999";
            document.body.appendChild(img);
        }, 100);
        
        setTimeout(() => {
            clearInterval(spamInterval);
            window.close();
            window.open("https://youtu.be/V6KOyFXXGh0?si=pbB58oUpnN4xQQQp", "_blank");
        }, 5000);
    }

    function saveProject() {
        let saveButton = document.querySelector("[data-control='save']");
        if (saveButton) {
            saveButton.click();
        }
    }

    document.addEventListener("click", function(event) {
        if (event.target.closest(".green-flag_green-flag_1kiAo")) {
            saveProject();
            playSound();
            spamImage();
        }
    });

})();