Skip to content

Commit dcd1ccd

Browse files
committed
Relax ModCDP server readiness version check
1 parent a4a1e8b commit dcd1ccd

10 files changed

Lines changed: 11 additions & 11 deletions

File tree

go/modcdp/client/ModCDPClient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var (
4343
extIDFromURL = regexp.MustCompile(`^chrome-extension://([a-z]+)/`)
4444
)
4545

46-
const modcdpReadyExpression = `Boolean(globalThis.ModCDP?.__ModCDPServerVersion === 1 && globalThis.ModCDP?.handleCommand && globalThis.ModCDP?.addCustomEvent)`
46+
const modcdpReadyExpression = `Boolean(globalThis.ModCDP?.__ModCDPServerVersion >= 1 && globalThis.ModCDP?.handleCommand && globalThis.ModCDP?.addCustomEvent)`
4747

4848
const DefaultCDPSendTimeoutMS = 10_000
4949
const DefaultEventWaitTimeoutMS = 10_000

go/modcdp/injector/BorrowedExtensionInjector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ const __name = (fn) => fn;
153153
%s
154154
const ModCDP = installModCDPServer(globalThis);
155155
return {
156-
ok: Boolean(ModCDP?.__ModCDPServerVersion === 1 && ModCDP?.handleCommand && ModCDP?.addCustomEvent),
156+
ok: Boolean(ModCDP?.__ModCDPServerVersion >= 1 && ModCDP?.handleCommand && ModCDP?.addCustomEvent),
157157
extension_id: globalThis.chrome?.runtime?.id ?? null,
158158
has_tabs: Boolean(globalThis.chrome?.tabs?.query),
159159
has_debugger: Boolean(globalThis.chrome?.debugger?.sendCommand && globalThis.chrome?.debugger?.getTargets),

go/modcdp/injector/ExtensionInjector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const DefaultTargetSessionPollIntervalMS = 20
2121
var DefaultModCDPServiceWorkerURLSuffixes = []string{"/modcdp/service_worker.js"}
2222
var extIDFromURL = regexp.MustCompile(`^chrome-extension://([a-z]+)/`)
2323

24-
const modcdpReadyExpression = `Boolean(globalThis.ModCDP?.__ModCDPServerVersion === 1 && globalThis.ModCDP?.handleCommand && globalThis.ModCDP?.addCustomEvent)`
24+
const modcdpReadyExpression = `Boolean(globalThis.ModCDP?.__ModCDPServerVersion >= 1 && globalThis.ModCDP?.handleCommand && globalThis.ModCDP?.addCustomEvent)`
2525

2626
type SendCDP = types.SendCDP
2727
type SessionIDForTarget = types.SessionIDForTarget

js/src/injector/BorrowedExtensionInjector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { ExtensionInjector, type ExtensionInjectionResult, type TargetInfo } fro
44

55
const EXT_ID_FROM_URL = /^chrome-extension:\/\/([a-z]+)\//;
66
const MODCDP_READY_EXPRESSION =
7-
"Boolean(globalThis.ModCDP?.__ModCDPServerVersion === 1 && globalThis.ModCDP?.handleCommand && globalThis.ModCDP?.addCustomEvent)";
7+
"Boolean(globalThis.ModCDP?.__ModCDPServerVersion >= 1 && globalThis.ModCDP?.handleCommand && globalThis.ModCDP?.addCustomEvent)";
88
const bootstrap_modcdp_server_expression = `
99
function() {
1010
const __name = (fn) => fn;
1111
const installModCDPServer = ${installModCDPServer.toString()};
1212
const ModCDP = installModCDPServer(globalThis);
1313
return {
14-
ok: Boolean(ModCDP?.__ModCDPServerVersion === 1 && ModCDP?.handleCommand && ModCDP?.addCustomEvent),
14+
ok: Boolean(ModCDP?.__ModCDPServerVersion >= 1 && ModCDP?.handleCommand && ModCDP?.addCustomEvent),
1515
extension_id: globalThis.chrome?.runtime?.id ?? null,
1616
has_tabs: Boolean(globalThis.chrome?.tabs?.query),
1717
has_debugger: Boolean(globalThis.chrome?.debugger?.sendCommand && globalThis.chrome?.debugger?.getTargets),

js/src/injector/ExtensionInjector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const DEFAULT_MODCDP_EXTENSION_ID = "mdedooklbnfejodmnhmkdpkaedafkehf";
99
export const DEFAULT_MODCDP_SERVICE_WORKER_URL_SUFFIXES = ["/modcdp/service_worker.js"];
1010
export const DEFAULT_MODCDP_WAKE_PATH = "/modcdp/wake.html";
1111
const MODCDP_READY_EXPRESSION =
12-
"Boolean(globalThis.ModCDP?.__ModCDPServerVersion === 1 && globalThis.ModCDP?.handleCommand && globalThis.ModCDP?.addCustomEvent)";
12+
"Boolean(globalThis.ModCDP?.__ModCDPServerVersion >= 1 && globalThis.ModCDP?.handleCommand && globalThis.ModCDP?.addCustomEvent)";
1313
export const DEFAULT_CDP_SEND_TIMEOUT_MS = 10_000;
1414
export const DEFAULT_EXECUTION_CONTEXT_TIMEOUT_MS = 10_000;
1515
export const DEFAULT_SERVICE_WORKER_PROBE_TIMEOUT_MS = 10_000;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "modcdp",
3-
"version": "0.0.10",
3+
"version": "0.0.11",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/pirate/modcdp.git"

python/modcdp/client/ModCDPClient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def ping(self, **params: Any):
164164
return self._client._send_command("Mod.ping", params)
165165

166166
MODCDP_READY_EXPRESSION = (
167-
"Boolean(globalThis.ModCDP?.__ModCDPServerVersion === 1 && "
167+
"Boolean(globalThis.ModCDP?.__ModCDPServerVersion >= 1 && "
168168
"globalThis.ModCDP?.handleCommand && globalThis.ModCDP?.addCustomEvent)"
169169
)
170170
DEFAULT_SERVER = object()

python/modcdp/injector/BorrowedExtensionInjector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def bootstrap_modcdp_server_expression() -> str:
105105
f"{installer}\n"
106106
"const ModCDP = installModCDPServer(globalThis);\n"
107107
"return {\n"
108-
" ok: Boolean(ModCDP?.__ModCDPServerVersion === 1 && ModCDP?.handleCommand && ModCDP?.addCustomEvent),\n"
108+
" ok: Boolean(ModCDP?.__ModCDPServerVersion >= 1 && ModCDP?.handleCommand && ModCDP?.addCustomEvent),\n"
109109
" extension_id: globalThis.chrome?.runtime?.id ?? null,\n"
110110
" has_tabs: Boolean(globalThis.chrome?.tabs?.query),\n"
111111
" has_debugger: Boolean(globalThis.chrome?.debugger?.sendCommand && globalThis.chrome?.debugger?.getTargets),\n"

python/modcdp/injector/ExtensionInjector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
DEFAULT_MODCDP_SERVICE_WORKER_URL_SUFFIXES = ["/modcdp/service_worker.js"]
1919
DEFAULT_MODCDP_WAKE_PATH = "/modcdp/wake.html"
2020
MODCDP_READY_EXPRESSION = (
21-
"Boolean(globalThis.ModCDP?.__ModCDPServerVersion === 1 && globalThis.ModCDP?.handleCommand && globalThis.ModCDP?.addCustomEvent)"
21+
"Boolean(globalThis.ModCDP?.__ModCDPServerVersion >= 1 && globalThis.ModCDP?.handleCommand && globalThis.ModCDP?.addCustomEvent)"
2222
)
2323
DEFAULT_CDP_SEND_TIMEOUT_MS = 10_000
2424
DEFAULT_EXECUTION_CONTEXT_TIMEOUT_MS = 10_000

python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "modcdp"
7-
version = "0.0.10"
7+
version = "0.0.11"
88
description = "Python client for ModCDP."
99
readme = "README.md"
1010
requires-python = ">=3.11"

0 commit comments

Comments
 (0)