您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
通过控制台导入 JS / CSS 库
当前为
- // ==UserScript==
- // @name Console Importer
- // @name:en Console Importer
- // @description 通过控制台导入 JS / CSS 库
- // @description:en Import JavaScript or CSS Library in browser developer tool.
- // @author Yiero
- // @version 1.0.1
- // @match https://*/*
- // @license GPL
- // @icon https://bbs.tampermonkey.net.cn/favicon.ico
- // @run-at document-body
- // @grant GM_addElement
- // @grant GM_xmlhttpRequest
- // @namespace https://github.com/AliubYiero/TamperMonkeyScripts/
- // @connect cdnjs.cloudflare.com
- // @connect cdn.bootcdn.net
- // @connect cdn.jsdelivr.net
- // ==/UserScript==
- function isCSS(url) {
- return url.endsWith("css");
- }
- const urlList = new Map;
- function getRequire(url) {
- if (urlList.has(url)) {
- console.error("[%s] \u83b7\u53d6\u6570\u636e\u5931\u8d25...\n\u5f53\u524d\u9875\u9762\u4e2d\u5df2\u5b58\u5728\u5e93 [%s]", "Console Importer", url);
- return;
- }
- console.info("[%s] \u6b63\u5728\u52a0\u8f7d\u6570\u636e...", "Console Importer");
- GM_xmlhttpRequest({
- method: "GET",
- url: url,
- onload(e) {
- const scriptText = e.responseText;
- const isScript = !isCSS(url);
- console.info("[%s] \u6210\u529f\u83b7\u53d6%s, \u6b63\u5728\u8f7d\u5165\u9875\u9762...", "Console Importer", isScript ? "\u811a\u672c" : "\u6837\u5f0f\u8868");
- const element = GM_addElement(document.head, isScript ? "script" : "style", {
- textContent: scriptText
- });
- urlList.set(url, element.id);
- console.info("[%s] %s\u8f7d\u5165\u6210\u529f.\n[%s]", "Console Importer", isScript ? "\u811a\u672c" : "\u6837\u5f0f\u8868", url);
- },
- onerror(e) {
- console.error("[%s] \u83b7\u53d6\u6570\u636e\u5931\u8d25...\nError: ", "Console Importer", e.error);
- }
- });
- }
- (() => {
- unsafeWindow.$i = getRequire;
- })();