mirror of
https://github.com/yaklang/yaklang-chrome-extension.git
synced 2026-09-27 05:31:53 +08:00
fix: 重复监听
This commit is contained in:
+10
-9
@@ -83,13 +83,14 @@ const pageFunction = (code) => {
|
||||
|
||||
chrome.runtime.onConnect.addListener(function (port) {
|
||||
console.assert(port.name === "content-to-ex");
|
||||
port.onMessage.addListener(function (msg) {
|
||||
console.log("[content-to-ex]", msg)
|
||||
});
|
||||
port.onDisconnect.addListener(function () {
|
||||
console.error("[content-to-ex] Disconnected from port.");
|
||||
});
|
||||
// port.postMessage({action: "TEST POST MESSAGE"});
|
||||
if (!port.hasListener) {
|
||||
port.onMessage.addListener(function (msg) {
|
||||
console.log("[content-to-ex]", msg)
|
||||
});
|
||||
port.onDisconnect.addListener(function () {
|
||||
console.error("[content-to-ex] Disconnected from port.");
|
||||
});
|
||||
// port.postMessage({action: "TEST POST MESSAGE"});
|
||||
port.hasListener = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user