Go Glitch Edit Page

Go Glitch Edit Page!

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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");
})();