This commit is contained in:
xuyanfeng
2021-04-26 22:27:47 +08:00
parent 0e04f8b708
commit 7b3ee52a6d
14 changed files with 239 additions and 201 deletions

View File

@@ -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
View 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)
}
}