Greasy Fork is available in English.
this script may be useful when your DevTools are disabled.
当前为
// ==UserScript==
// @name:zh-CN 控制台EZ
// @name EZ Console
// @namespace Violentmonkey Scripts
// @match *://*/*
// @license AGPL-3.0-or-later
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// @grant GM_addElement
// @version 0.3
// @author -
// @description:zh-cn 用于在环境严重受限(如手机) 或 有较强 Anti-DevTools 的网站使用
// @description:en -
// @description this script may be useful when your DevTools are disabled.
// ==/UserScript==
const evaler = sandbox => code => {
with (sandbox)
try {eval(code);}
catch(e) {console.error(e);}
};
let x = GM_registerMenuCommand("控制台EZ", () => {
'use strict';
GM_unregisterMenuCommand(x);
const div = GM_addElement("div", {
style: "left: 0px;position: fixed;top: 0px;z-index: 9999; display:flex; flex-direction: column; width: 50vh;"
});
const ipt = GM_addElement(div, "input", {
style: "border: solid;flex: 0 0 auto;"
});
const ppt = GM_addElement(div, "textarea", {style: "flex: 1 0 auto;"});
const log = (...args) => (args.forEach(t => ppt.value += t), ppt.value += "\n");
const eval2 = evaler({
console: {
log,
warn: (...args) => log("[WARN] ", ...args),
error: (...args) => log("[ERR] ", ...args),
}
});
ipt.addEventListener("keypress", e => {
if (e.key === "Enter") {
let t = ipt.value;
eval2(t);
ipt.value = "";
}
});
});