mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-19 08:28:41 +00:00
1
This commit is contained in:
parent
47744fd87e
commit
3b9726f284
@ -1,7 +1,7 @@
|
|||||||
export function injectScript(url: string) {
|
export function injectScript(url: string) {
|
||||||
if (chrome && chrome.extension && chrome.extension.getURL) {
|
if (chrome && chrome.extension && chrome.extension.getURL) {
|
||||||
let content = chrome.extension.getURL(url)
|
let content = chrome.extension.getURL(url)
|
||||||
console.log(`[cc-inspector]注入脚本:${content}`);
|
console.log(`[cc-inspector] inject script: ${content}`);
|
||||||
const script = document.createElement("script")
|
const script = document.createElement("script")
|
||||||
script.setAttribute("type", "text/javascript")
|
script.setAttribute("type", "text/javascript")
|
||||||
script.setAttribute("src", content)
|
script.setAttribute("src", content)
|
||||||
@ -12,7 +12,6 @@ export function injectScript(url: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
interface LogOptions {
|
interface LogOptions {
|
||||||
data: any;
|
data: any;
|
||||||
flag?: string;
|
flag?: string;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
// content.js 和原始界面共享DOM,具有操作dom的能力
|
// content.js 和原始界面共享DOM,具有操作dom的能力
|
||||||
// 但是不共享js,要想访问页面js,只能通过注入的方式
|
// 但是不共享js,要想访问页面js,只能通过注入的方式
|
||||||
import {injectScript} from "../core/util";
|
import { injectScript } from "../core/util";
|
||||||
import {Msg, Page, PluginEvent} from "../core/types";
|
import { Msg, Page, PluginEvent } from "../core/types";
|
||||||
|
import { ChromeConst } from "cc-plugin/src/chrome/const";
|
||||||
injectScript("js/inject.js");
|
injectScript(ChromeConst.script.inject);
|
||||||
|
|
||||||
class Content {
|
class Content {
|
||||||
private connect: chrome.runtime.Port | null = null;
|
private connect: chrome.runtime.Port | null = null;
|
||||||
@ -22,7 +22,7 @@ class Content {
|
|||||||
|
|
||||||
// 和background.js保持长连接通讯,background和content的交互也要通过这个链接进行通讯
|
// 和background.js保持长连接通讯,background和content的交互也要通过这个链接进行通讯
|
||||||
private connectToBackground() {
|
private connectToBackground() {
|
||||||
this.connect = chrome.runtime.connect({name: Page.Content})
|
this.connect = chrome.runtime.connect({ name: Page.Content })
|
||||||
this.connect.onMessage.addListener((data: PluginEvent, sender) => {
|
this.connect.onMessage.addListener((data: PluginEvent, sender) => {
|
||||||
if (PluginEvent.check(data, Page.Background, Page.Content)) {
|
if (PluginEvent.check(data, Page.Background, Page.Content)) {
|
||||||
// console.log(`%c[Connect-Message] ${JSON.stringify(data)}`, "color:green;")
|
// console.log(`%c[Connect-Message] ${JSON.stringify(data)}`, "color:green;")
|
||||||
@ -39,7 +39,7 @@ class Content {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async run() {
|
run() {
|
||||||
this.connectToBackground();
|
this.connectToBackground();
|
||||||
this.checkGame();
|
this.checkGame();
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import CCP from "cc-plugin/src/ccp/entry-render";
|
|||||||
import pluginConfig from "../../../cc-plugin.config";
|
import pluginConfig from "../../../cc-plugin.config";
|
||||||
import ccui from "@xuyanfeng/cc-ui";
|
import ccui from "@xuyanfeng/cc-ui";
|
||||||
import "@xuyanfeng/cc-ui/dist/ccui.css";
|
import "@xuyanfeng/cc-ui/dist/ccui.css";
|
||||||
|
import "@xuyanfeng/cc-ui/iconfont/use.css";
|
||||||
import "@xuyanfeng/cc-ui/iconfont/iconfont.css";
|
import "@xuyanfeng/cc-ui/iconfont/iconfont.css";
|
||||||
|
|
||||||
export default CCP.init(pluginConfig, {
|
export default CCP.init(pluginConfig, {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<div class="name">{{ title }}</div>
|
<div class="name">{{ title }}</div>
|
||||||
<div style="flex: 1"></div>
|
<div style="flex: 1"></div>
|
||||||
<CCButton @click="onClickOptions">
|
<CCButton @click="onClickOptions">
|
||||||
<i class="iconfont icon_setting"></i>
|
<i class="iconfont icon_settings"></i>
|
||||||
</CCButton>
|
</CCButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -93,10 +93,6 @@ export default defineComponent({
|
|||||||
</script>
|
</script>
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.popup {
|
.popup {
|
||||||
widows: 10px;
|
|
||||||
height: 10px;
|
|
||||||
background-color: rebeccapurple;
|
|
||||||
|
|
||||||
width: 300px;
|
width: 300px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user