Go Glitch Edit Page

Go Glitch Edit Page!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Go Glitch Edit Page
// @namespace    GoGlitchEditPage
// @version      1.0.4
// @description  Go Glitch Edit Page!
// @author       Runterya
// @homepage     https://github.com/Runteryaa
// @match        *://*.glitch.me/*
// @grant        none
// @license      MIT
// @compatible   chrome
// @compatible   edge
// @compatible   firefox
// @compatible   opera
// @compatible   safari
// ==/UserScript==

// Add a button to the top right corner of the page that redirects to the Glitch editor.
(function() {
    'use strict';

    // Check if the current domain is "glitch.me"
    if (window.location.hostname.endsWith("glitch.me")) {
        // Create the GEP button
        var gepButton = document.createElement('button');
        gepButton.innerHTML = 'GEP';
        gepButton.title = 'Go Glitch Edit Page';
        gepButton.style.position = 'fixed';
        gepButton.style.top = '3px';
        gepButton.style.right = '3px';
        gepButton.style.zIndex = '9999';
        gepButton.style.fontSize = '10px';
        gepButton.style.padding = '.5px 1px';

        // Add an event listener to redirect on button click
        gepButton.addEventListener('click', function() {
            var projectName = window.location.hostname.split('.')[0];
            var redirectUrl = 'https://glitch.com/edit/#!/' + projectName;
            window.location.href = redirectUrl;
        });

        // Append the button to the body
        document.body.appendChild(gepButton);
    }

    // Loaded
    console.log("Go Glitch Edit Page");
})();