您需要先安装一个扩展,例如 篡改猴、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.0
- // @match https://*/*
- // @run-at document-body
- // @license GPL
- // @icon https://bbs.tampermonkey.net.cn/favicon.ico
- // @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;
- }
- GM_xmlhttpRequest( {
- method: "GET",
- url: url,
- onload( e ) {
- const scriptText = e.responseText;
- const isScript = isCSS( url );
- const element = GM_addElement( document.head, isScript ? "script" : "style", {
- textContent: scriptText
- } );
- urlList.set( url, element.id );
- },
- onerror( e ) {
- console.error( "[%s] \u83b7\u53d6\u6570\u636e\u5931\u8d25...\n", "Console Importer", e );
- }
- } );
- }
- ( () => {
- unsafeWindow.$i = getRequire;
- } )();