Code Executer

Execute code on any websites!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Code Executer
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Execute code on any websites!
// @author       cool
// @match        *://*/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license      MIT
// ==/UserScript==

(function(w) {
    'use strict';
    var _codeExecuteio = false;
    var _codeExecutec = document.createElement("button");
    _codeExecutec.setAttribute("style", "width: 80px !important; height: 40px !important; padding: 0px !important; margin: 0px !important; text-size: 14px !important; background-color: dodgerblue !important; color: white !important; border: none !important; border-radius: 5px 0px 5px 0px !important; position: fixed !important; right: 0px !important; bottom: 0px !important; z-index: 99999999 !important; cursor: pointer !important;");
    _codeExecutec.innerHTML = "Code Execute";
    document.body.appendChild(_codeExecutec);
    var _codeExecutei = document.createElement("input");
    _codeExecutei.setAttribute("style", "width: calc(100% - 90px) !important; padding: 0px 5px !important; margin: 0px !important; height: 40px !important; text-size: 14px !important; background-color: white !important; color: black !important; outline: none !important; border: 1px solid gray !important; border-radius: 0px !important; position: fixed !important; left: 0px !important; bottom: 0px !important; z-index: 99999999 !important; cursor: text !important;");
    _codeExecutei.placeholder = "Press enter to execute";
    _codeExecutei.hidden = true;
    document.body.appendChild(_codeExecutei);
    _codeExecutec.addEventListener("click", function() {
        if (_codeExecuteio) {
            _codeExecuteio = false;
            _codeExecutei.hidden = true;
            _codeExecutec.innerHTML = "Code Execute";
        } else {
            _codeExecuteio = true;
            _codeExecutei.hidden = false;
            _codeExecutec.innerHTML = "Close";
            _codeExecutei.focus();
        }
    });
    _codeExecutei.addEventListener("keydown", function(e) {
        if (e.key == "Enter") {
            (function(window, _codeExecuteCode) {
                eval(_codeExecuteCode);
            })(w, _codeExecutei.value);
            _codeExecutei.value = "";
        }
    });
})(window);