mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-10-23 01:55:25 +00:00
重构
This commit is contained in:
@@ -1,15 +1,29 @@
|
||||
export const Page = {
|
||||
Inject: "Inject",
|
||||
Devtools: "Devtools",
|
||||
DevToolsPanel: "DevToolsPanel",
|
||||
Content: "Content",
|
||||
Popup: "Popup",
|
||||
Options: "Options",
|
||||
}
|
||||
export const Msg = {
|
||||
NodeInfo: "node_info",// 具体的节点信息
|
||||
ListInfo: "list_info",// 节点树信息
|
||||
Support: "game_support",// 游戏支持信息
|
||||
MemoryInfo: "memory_info",//
|
||||
UrlChange: "url_change",
|
||||
NodeInfo: "node-info",// 具体的节点信息
|
||||
TreeInfo: "tree-info",// 节点树信息
|
||||
Support: "game-support",// 游戏支持信息
|
||||
MemoryInfo: "memory-info",//
|
||||
TabsInfo: "tabs_info", // 当前页面信息
|
||||
UrlChange: "url_change", // 网址发生变化
|
||||
SetProperty: "set-property", // 设置node属性
|
||||
}
|
||||
|
||||
export function MsgInclude(msg: string) {
|
||||
for (let key in Msg) {
|
||||
if (Msg.hasOwnProperty(key)) {
|
||||
//@ts-ignore
|
||||
let m = Msg[key] as string;
|
||||
if (m === msg) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
13
source/src/core/util.ts
Normal file
13
source/src/core/util.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export function injectScript(url: string) {
|
||||
if (chrome && chrome.extension && chrome.extension.getURL) {
|
||||
let content = chrome.extension.getURL(url)
|
||||
console.log(`[cc-inspector]注入脚本:${content}`);
|
||||
let script = document.createElement('script')
|
||||
script.setAttribute('type', 'text/javascript')
|
||||
script.setAttribute('src', content)
|
||||
script.onload = function () {
|
||||
document.body.removeChild(script);
|
||||
}
|
||||
document.body.appendChild(script)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user