Scratch to TurboWarp

Adds a button to Scratch projects that links to TurboWarp

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Scratch to TurboWarp
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Adds a button to Scratch projects that links to TurboWarp
// @author       c00lk1dha4k3r -- a scratch user
// @match        https://scratch.mit.edu/projects/*
// @icon         https://www.turbowarp.org/favicon.ico
// @grant        none
// @license GNU
// ==/UserScript==

(function() {
    'use strict';

    // Function to create the TurboWarp button
    function createTurboWarpButton() {
        const projectId = window.location.pathname.split('/')[2];
        const turboWarpUrl = `https://www.turbowarp.org/${projectId}`;

        const button = document.createElement('a');
        button.href = turboWarpUrl;
        button.innerText = 'Open in TurboWarp';
        button.style.position = 'absolute';
        button.style.top = '10px';
        button.style.right = '10px';
        button.style.padding = '10px 20px';
        button.style.backgroundColor = '#ff9500';
        button.style.color = '#fff';
        button.style.border = 'none';
        button.style.borderRadius = '5px';
        button.style.textDecoration = 'none';
        button.style.fontSize = '16px';
        button.style.fontWeight = 'bold';
        button.style.cursor = 'pointer';
        button.style.zIndex = '1000';

        document.body.appendChild(button);
    }

    // Wait until the page content is fully loaded
    window.addEventListener('load', createTurboWarpButton);
})();