Created
April 10, 2023 13:58
-
-
Save Mufanc/9b060e2f632fe51c5afb77420948c89e to your computer and use it in GitHub Desktop.
向网页注入 vConsole
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name vConsole | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0 | |
// @description Inject vConsole | |
// @author Mufanc | |
// @grant unsafeWindow | |
// @grant GM_registerMenuCommand | |
// @run-at document-start | |
// @match *://*/* | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
GM_registerMenuCommand("vConsole", () => { | |
const head = document.getElementsByTagName('head')[0]; | |
const script = document.createElement('script'); | |
script.innerHTML = 'function __vConsole__() { setTimeout(() => { var vConsole = new window.VConsole(); }, 1000) }'; | |
head.appendChild(script); | |
const cdn = document.createElement('script'); | |
cdn.src = 'https://unpkg.com/vconsole@latest/dist/vconsole.min.js'; | |
cdn.onload = function () { | |
unsafeWindow.__vConsole__(); | |
} | |
head.appendChild(cdn); | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment