@wordbricks/playwright-mcp 0.1.25 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browserContextFactory.js +616 -0
- package/lib/browserServerBackend.js +86 -0
- package/lib/config.js +302 -0
- package/lib/context.js +320 -0
- package/lib/extension/cdpRelay.js +352 -0
- package/lib/extension/extensionContextFactory.js +56 -0
- package/lib/frameworkPatterns.js +35 -0
- package/lib/hooks/antiBotDetectionHook.js +178 -0
- package/lib/hooks/core.js +145 -0
- package/lib/hooks/eventConsumer.js +52 -0
- package/lib/hooks/events.js +42 -0
- package/lib/hooks/formatToolCallEvent.js +12 -0
- package/lib/hooks/frameworkStateHook.js +182 -0
- package/lib/hooks/grouping.js +72 -0
- package/lib/hooks/jsonLdDetectionHook.js +182 -0
- package/lib/hooks/networkFilters.js +82 -0
- package/lib/hooks/networkSetup.js +61 -0
- package/lib/hooks/networkTrackingHook.js +67 -0
- package/lib/hooks/pageHeightHook.js +75 -0
- package/lib/hooks/registry.js +41 -0
- package/lib/hooks/requireTabHook.js +26 -0
- package/lib/hooks/schema.js +89 -0
- package/lib/hooks/waitHook.js +33 -0
- package/lib/index.js +41 -0
- package/lib/mcp/inProcessTransport.js +71 -0
- package/lib/mcp/proxyBackend.js +130 -0
- package/lib/mcp/server.js +91 -0
- package/lib/mcp/tool.js +44 -0
- package/lib/mcp/transport.js +188 -0
- package/lib/playwrightTransformer.js +520 -0
- package/lib/program.js +112 -0
- package/lib/response.js +192 -0
- package/lib/sessionLog.js +123 -0
- package/lib/tab.js +251 -0
- package/lib/tools/common.js +55 -0
- package/lib/tools/console.js +33 -0
- package/lib/tools/dialogs.js +50 -0
- package/lib/tools/evaluate.js +62 -0
- package/lib/tools/extractFrameworkState.js +225 -0
- package/lib/tools/files.js +48 -0
- package/lib/tools/form.js +66 -0
- package/lib/tools/getSnapshot.js +36 -0
- package/lib/tools/getVisibleHtml.js +68 -0
- package/lib/tools/install.js +51 -0
- package/lib/tools/keyboard.js +83 -0
- package/lib/tools/mouse.js +97 -0
- package/lib/tools/navigate.js +66 -0
- package/lib/tools/network.js +121 -0
- package/lib/tools/networkDetail.js +238 -0
- package/lib/tools/networkSearch/bodySearch.js +161 -0
- package/lib/tools/networkSearch/grouping.js +37 -0
- package/lib/tools/networkSearch/helpers.js +32 -0
- package/lib/tools/networkSearch/searchHtml.js +76 -0
- package/lib/tools/networkSearch/types.js +1 -0
- package/lib/tools/networkSearch/urlSearch.js +124 -0
- package/lib/tools/networkSearch.js +278 -0
- package/lib/tools/pdf.js +41 -0
- package/lib/tools/repl.js +414 -0
- package/lib/tools/screenshot.js +103 -0
- package/lib/tools/scroll.js +131 -0
- package/lib/tools/snapshot.js +161 -0
- package/lib/tools/tabs.js +62 -0
- package/lib/tools/tool.js +35 -0
- package/lib/tools/utils.js +78 -0
- package/lib/tools/wait.js +60 -0
- package/lib/tools.js +68 -0
- package/lib/utils/adBlockFilter.js +90 -0
- package/lib/utils/codegen.js +55 -0
- package/lib/utils/extensionPath.js +10 -0
- package/lib/utils/fileUtils.js +40 -0
- package/lib/utils/graphql.js +269 -0
- package/lib/utils/guid.js +22 -0
- package/lib/utils/httpServer.js +39 -0
- package/lib/utils/log.js +21 -0
- package/lib/utils/manualPromise.js +111 -0
- package/lib/utils/networkFormat.js +14 -0
- package/lib/utils/package.js +20 -0
- package/lib/utils/result.js +2 -0
- package/lib/utils/sanitizeHtml.js +130 -0
- package/lib/utils/truncate.js +103 -0
- package/lib/utils/withTimeout.js +7 -0
- package/package.json +11 -1
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { withTimeout } from "../../utils/withTimeout.js";
|
|
2
|
+
import { highlightMatch } from "./helpers.js";
|
|
3
|
+
import { searchInHtml } from "./searchHtml.js";
|
|
4
|
+
const CONTEXT_LENGTH_BODY = 400;
|
|
5
|
+
const CONTEXT_LENGTH_DEFAULT = 300;
|
|
6
|
+
const MAX_SEARCH_DEPTH = 20;
|
|
7
|
+
export const searchInObject = (obj, keyword, path, matches, source, depth = 0) => {
|
|
8
|
+
if (depth > MAX_SEARCH_DEPTH || !obj || typeof obj !== "object")
|
|
9
|
+
return;
|
|
10
|
+
for (const key in obj) {
|
|
11
|
+
const newPath = path ? `${path}.${key}` : key;
|
|
12
|
+
const value = obj[key];
|
|
13
|
+
if (key.toLowerCase().includes(keyword)) {
|
|
14
|
+
const highlightedKey = highlightMatch(key, keyword, CONTEXT_LENGTH_DEFAULT);
|
|
15
|
+
const valueContext = typeof value === "object" && value !== null
|
|
16
|
+
? truncateJsonPreview(value)
|
|
17
|
+
: truncateStringPreview(String(value));
|
|
18
|
+
matches.push({
|
|
19
|
+
path: newPath,
|
|
20
|
+
value: typeof value === "object" && value !== null
|
|
21
|
+
? JSON.stringify(value)
|
|
22
|
+
: String(value),
|
|
23
|
+
context: `${highlightedKey}: ${valueContext}`,
|
|
24
|
+
source,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (typeof value === "string" && value.toLowerCase().includes(keyword)) {
|
|
28
|
+
matches.push({
|
|
29
|
+
path: newPath,
|
|
30
|
+
value: value,
|
|
31
|
+
context: `${key}: ${highlightMatch(value, keyword, CONTEXT_LENGTH_DEFAULT)}`,
|
|
32
|
+
source,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else if (typeof value === "number" && String(value).includes(keyword)) {
|
|
36
|
+
const valueStr = String(value);
|
|
37
|
+
matches.push({
|
|
38
|
+
path: newPath,
|
|
39
|
+
value: valueStr,
|
|
40
|
+
context: `${key}: ${highlightMatch(valueStr, keyword, CONTEXT_LENGTH_DEFAULT)}`,
|
|
41
|
+
source,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (typeof value === "object" && value !== null)
|
|
45
|
+
searchInObject(value, keyword, newPath, matches, source, depth + 1);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const truncateStringPreview = (text) => text.length > CONTEXT_LENGTH_DEFAULT
|
|
49
|
+
? text.slice(0, CONTEXT_LENGTH_DEFAULT) + "..."
|
|
50
|
+
: text;
|
|
51
|
+
const truncateJsonPreview = (obj) => {
|
|
52
|
+
try {
|
|
53
|
+
return JSON.stringify(obj).slice(0, CONTEXT_LENGTH_BODY) + "...";
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return "[Object]";
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
export const searchInRequestBody = (request, keyword, matches) => {
|
|
60
|
+
const body = request.postData();
|
|
61
|
+
if (!body || !body.toLowerCase().includes(keyword))
|
|
62
|
+
return;
|
|
63
|
+
const requestContentType = request.headers()["content-type"] || "";
|
|
64
|
+
let handled = false;
|
|
65
|
+
if (requestContentType.includes("application/json") ||
|
|
66
|
+
body.trim().startsWith("{") ||
|
|
67
|
+
body.trim().startsWith("[")) {
|
|
68
|
+
try {
|
|
69
|
+
const parsed = JSON.parse(body);
|
|
70
|
+
searchInObject(parsed, keyword, "request.body", matches, "requestBody");
|
|
71
|
+
handled = true;
|
|
72
|
+
}
|
|
73
|
+
catch { }
|
|
74
|
+
}
|
|
75
|
+
if (!handled &&
|
|
76
|
+
(requestContentType.includes("text/html") || body.trim().startsWith("<"))) {
|
|
77
|
+
searchInHtml(body, keyword, "request.body", matches, "requestBody");
|
|
78
|
+
handled = true;
|
|
79
|
+
}
|
|
80
|
+
if (!handled &&
|
|
81
|
+
requestContentType.includes("application/x-www-form-urlencoded")) {
|
|
82
|
+
try {
|
|
83
|
+
const sp = new URLSearchParams(body);
|
|
84
|
+
for (const [k, v] of sp.entries()) {
|
|
85
|
+
const vStr = v || "";
|
|
86
|
+
if (!vStr.toLowerCase().includes(keyword))
|
|
87
|
+
continue;
|
|
88
|
+
const trimmed = vStr.trim();
|
|
89
|
+
let parsedOk = false;
|
|
90
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
91
|
+
try {
|
|
92
|
+
const parsed = JSON.parse(trimmed);
|
|
93
|
+
searchInObject(parsed, keyword, `request.body.form.${k}`, matches, "requestBody");
|
|
94
|
+
parsedOk = true;
|
|
95
|
+
}
|
|
96
|
+
catch { }
|
|
97
|
+
}
|
|
98
|
+
if (!parsedOk) {
|
|
99
|
+
matches.push({
|
|
100
|
+
path: `request.body.form.${k}`,
|
|
101
|
+
value: vStr,
|
|
102
|
+
context: `${k}=${highlightMatch(vStr, keyword, CONTEXT_LENGTH_DEFAULT)}`,
|
|
103
|
+
source: "requestBody",
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
handled = true;
|
|
108
|
+
}
|
|
109
|
+
catch { }
|
|
110
|
+
}
|
|
111
|
+
if (!handled) {
|
|
112
|
+
matches.push({
|
|
113
|
+
path: "request.body",
|
|
114
|
+
value: body,
|
|
115
|
+
context: highlightMatch(body, keyword, CONTEXT_LENGTH_BODY),
|
|
116
|
+
source: "requestBody",
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
export const searchInResponseBody = async (response, keyword, matches) => {
|
|
121
|
+
const contentTypeHeader = response.headers()["content-type"] || "";
|
|
122
|
+
if (!(contentTypeHeader.startsWith("text/") ||
|
|
123
|
+
contentTypeHeader.includes("application/json") ||
|
|
124
|
+
contentTypeHeader.includes("application/xml")))
|
|
125
|
+
return;
|
|
126
|
+
try {
|
|
127
|
+
const responseBody = await withTimeout(response.text(), 2000);
|
|
128
|
+
if (!responseBody || !responseBody.toLowerCase().includes(keyword))
|
|
129
|
+
return;
|
|
130
|
+
let handled = false;
|
|
131
|
+
const trimmed = responseBody.trimStart();
|
|
132
|
+
const xssiPrefix = ")]}'";
|
|
133
|
+
const hasXssi = trimmed.startsWith(xssiPrefix);
|
|
134
|
+
const jsonCandidate = hasXssi ? trimmed.slice(xssiPrefix.length) : trimmed;
|
|
135
|
+
if (contentTypeHeader.includes("application/json") ||
|
|
136
|
+
jsonCandidate.startsWith("{") ||
|
|
137
|
+
jsonCandidate.startsWith("[")) {
|
|
138
|
+
try {
|
|
139
|
+
const parsed = JSON.parse(jsonCandidate);
|
|
140
|
+
searchInObject(parsed, keyword, "response.body", matches, "responseBody");
|
|
141
|
+
handled = true;
|
|
142
|
+
}
|
|
143
|
+
catch { }
|
|
144
|
+
}
|
|
145
|
+
if (!handled &&
|
|
146
|
+
(contentTypeHeader.includes("text/html") ||
|
|
147
|
+
responseBody.trim().startsWith("<"))) {
|
|
148
|
+
searchInHtml(responseBody, keyword, "response.body", matches, "responseBody");
|
|
149
|
+
handled = true;
|
|
150
|
+
}
|
|
151
|
+
if (!handled) {
|
|
152
|
+
matches.push({
|
|
153
|
+
path: "response.body",
|
|
154
|
+
value: responseBody,
|
|
155
|
+
context: highlightMatch(responseBody, keyword, CONTEXT_LENGTH_BODY),
|
|
156
|
+
source: "responseBody",
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch { }
|
|
161
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const normalizePath = (path) => {
|
|
2
|
+
if (path.includes(" > "))
|
|
3
|
+
return path.replace(/:nth-child\(\d+\)/g, ":nth-child(*)");
|
|
4
|
+
return path.replace(/\.(?:\d+)(?=\.|$)/g, ".*");
|
|
5
|
+
};
|
|
6
|
+
export const getDepth = (path) => {
|
|
7
|
+
const separators = path.match(/\.|>/g) || [];
|
|
8
|
+
return separators.length;
|
|
9
|
+
};
|
|
10
|
+
export const mergeGroupedMatches = (a, b) => {
|
|
11
|
+
const map = new Map();
|
|
12
|
+
for (const g of a)
|
|
13
|
+
map.set(g.normalized, {
|
|
14
|
+
normalized: g.normalized,
|
|
15
|
+
count: g.count,
|
|
16
|
+
examples: g.examples.slice(0, 3),
|
|
17
|
+
});
|
|
18
|
+
for (const g of b) {
|
|
19
|
+
const existing = map.get(g.normalized);
|
|
20
|
+
if (existing) {
|
|
21
|
+
existing.count += g.count;
|
|
22
|
+
for (const e of g.examples) {
|
|
23
|
+
if (existing.examples.length < 3 &&
|
|
24
|
+
!existing.examples.some((x) => x.context === e.context))
|
|
25
|
+
existing.examples.push(e);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
map.set(g.normalized, {
|
|
30
|
+
normalized: g.normalized,
|
|
31
|
+
count: g.count,
|
|
32
|
+
examples: g.examples.slice(0, 3),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return Array.from(map.values());
|
|
37
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { truncateStringTo } from "../../utils/truncate.js";
|
|
2
|
+
export const parseKeywordParams = (keyword) => {
|
|
3
|
+
const out = [];
|
|
4
|
+
try {
|
|
5
|
+
const sp = new URLSearchParams(keyword);
|
|
6
|
+
sp.forEach((value, key) => {
|
|
7
|
+
if (key)
|
|
8
|
+
out.push({ name: key, value });
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
catch { }
|
|
12
|
+
return out;
|
|
13
|
+
};
|
|
14
|
+
export const highlightMatch = (text, keyword, maxLength = 50) => {
|
|
15
|
+
const lowerText = text.toLowerCase();
|
|
16
|
+
const index = lowerText.indexOf(keyword);
|
|
17
|
+
if (index === -1)
|
|
18
|
+
return truncateStringTo(text, maxLength).text;
|
|
19
|
+
const contextBefore = Math.floor((maxLength - keyword.length) / 2);
|
|
20
|
+
const contextAfter = maxLength - keyword.length - contextBefore;
|
|
21
|
+
const start = Math.max(0, index - contextBefore);
|
|
22
|
+
const end = Math.min(text.length, index + keyword.length + contextAfter);
|
|
23
|
+
let result = "";
|
|
24
|
+
if (start > 0)
|
|
25
|
+
result += "...";
|
|
26
|
+
result += text.substring(start, index);
|
|
27
|
+
result += text.substring(index, index + keyword.length);
|
|
28
|
+
result += text.substring(index + keyword.length, end);
|
|
29
|
+
if (end < text.length)
|
|
30
|
+
result += "...";
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as cheerio from "cheerio";
|
|
2
|
+
import { highlightMatch } from "./helpers.js";
|
|
3
|
+
export const getElementPath = ($el) => {
|
|
4
|
+
const path = [];
|
|
5
|
+
let current = $el;
|
|
6
|
+
while (current.length &&
|
|
7
|
+
current[0].type === "tag" &&
|
|
8
|
+
current[0].name !== "html") {
|
|
9
|
+
let selector = current[0].name.toLowerCase();
|
|
10
|
+
const id = current.attr("id");
|
|
11
|
+
if (id) {
|
|
12
|
+
selector += `#${id}`;
|
|
13
|
+
path.unshift(selector);
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
const classes = current.attr("class");
|
|
17
|
+
if (classes)
|
|
18
|
+
selector += `.${classes.trim().split(/\s+/).join(".")}`;
|
|
19
|
+
const tagName = current[0].type === "tag" ? current[0].name : "";
|
|
20
|
+
const siblings = current
|
|
21
|
+
.parent()
|
|
22
|
+
.children()
|
|
23
|
+
.filter((_, el) => el.type === "tag" && el.name === tagName);
|
|
24
|
+
if (siblings.length > 1) {
|
|
25
|
+
const index = siblings.index(current) + 1;
|
|
26
|
+
selector += `:nth-child(${index})`;
|
|
27
|
+
}
|
|
28
|
+
path.unshift(selector);
|
|
29
|
+
current = current.parent();
|
|
30
|
+
}
|
|
31
|
+
return path.join(" > ");
|
|
32
|
+
};
|
|
33
|
+
export const searchInHtml = (html, keyword, basePath, matches, source) => {
|
|
34
|
+
const $ = cheerio.load(html);
|
|
35
|
+
$("*")
|
|
36
|
+
.contents()
|
|
37
|
+
.each((_, node) => {
|
|
38
|
+
if (node.type === "text") {
|
|
39
|
+
const text = (node.data || "").trim();
|
|
40
|
+
if (text && text.toLowerCase().includes(keyword)) {
|
|
41
|
+
const parent = $(node).parent();
|
|
42
|
+
if (parent.length) {
|
|
43
|
+
const elPath = getElementPath(parent);
|
|
44
|
+
const path = elPath ? `${basePath} > ${elPath}` : basePath;
|
|
45
|
+
matches.push({
|
|
46
|
+
path,
|
|
47
|
+
value: text,
|
|
48
|
+
context: highlightMatch(text, keyword, 300),
|
|
49
|
+
source,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
$("*").each((_, el) => {
|
|
56
|
+
if (el.type === "tag") {
|
|
57
|
+
const attrs = el.attribs;
|
|
58
|
+
if (attrs) {
|
|
59
|
+
Object.entries(attrs).forEach(([key, val]) => {
|
|
60
|
+
if (typeof val === "string" && val.toLowerCase().includes(keyword)) {
|
|
61
|
+
const elPath = getElementPath($(el));
|
|
62
|
+
const path = elPath
|
|
63
|
+
? `${basePath} > ${elPath}@${key}`
|
|
64
|
+
: `${basePath}@${key}`;
|
|
65
|
+
matches.push({
|
|
66
|
+
path,
|
|
67
|
+
value: val,
|
|
68
|
+
context: highlightMatch(val, keyword, 300),
|
|
69
|
+
source,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { highlightMatch } from "./helpers.js";
|
|
2
|
+
const CONTEXT_LENGTH_DEFAULT = 300;
|
|
3
|
+
export const searchInUrls = (request, response, keyword, keywordParams, matches) => {
|
|
4
|
+
try {
|
|
5
|
+
const reqUrl = request.url();
|
|
6
|
+
const reqUrlLower = reqUrl.toLowerCase();
|
|
7
|
+
const keywordPathOnly = keyword.split("?")[0];
|
|
8
|
+
if (reqUrlLower.includes(keyword)) {
|
|
9
|
+
matches.push({
|
|
10
|
+
path: "request.url",
|
|
11
|
+
value: reqUrl,
|
|
12
|
+
context: `url: ${highlightMatch(reqUrl, keyword, CONTEXT_LENGTH_DEFAULT)}`,
|
|
13
|
+
source: "requestUrl",
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
else if (keywordPathOnly && reqUrlLower.includes(keywordPathOnly)) {
|
|
17
|
+
matches.push({
|
|
18
|
+
path: "request.url",
|
|
19
|
+
value: reqUrl,
|
|
20
|
+
context: `url: ${highlightMatch(reqUrl, keywordPathOnly, CONTEXT_LENGTH_DEFAULT)}`,
|
|
21
|
+
source: "requestUrl",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
try {
|
|
26
|
+
const u = new URL(reqUrl);
|
|
27
|
+
const pathnameLower = u.pathname.toLowerCase();
|
|
28
|
+
if (pathnameLower.includes(keyword) ||
|
|
29
|
+
(keywordPathOnly && pathnameLower.includes(keywordPathOnly)))
|
|
30
|
+
matches.push({
|
|
31
|
+
path: "request.url",
|
|
32
|
+
value: reqUrl,
|
|
33
|
+
context: `url: ${highlightMatch(reqUrl, keywordPathOnly || keyword, CONTEXT_LENGTH_DEFAULT)}`,
|
|
34
|
+
source: "requestUrl",
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch { }
|
|
38
|
+
}
|
|
39
|
+
if (keywordParams.length) {
|
|
40
|
+
try {
|
|
41
|
+
const u = new URL(reqUrl);
|
|
42
|
+
for (const { name, value } of keywordParams) {
|
|
43
|
+
if (!name)
|
|
44
|
+
continue;
|
|
45
|
+
const pageVal = u.searchParams.get(name);
|
|
46
|
+
if (!pageVal)
|
|
47
|
+
continue;
|
|
48
|
+
const valLower = (value || "").toLowerCase();
|
|
49
|
+
if (!valLower)
|
|
50
|
+
continue;
|
|
51
|
+
const pageValLower = pageVal.toLowerCase();
|
|
52
|
+
if (pageValLower.includes(valLower))
|
|
53
|
+
matches.push({
|
|
54
|
+
path: `request.url.query.${name}`,
|
|
55
|
+
value: pageVal,
|
|
56
|
+
context: `${name}=${highlightMatch(pageVal, value, CONTEXT_LENGTH_DEFAULT)}`,
|
|
57
|
+
source: "requestUrl",
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch { }
|
|
62
|
+
}
|
|
63
|
+
if (response) {
|
|
64
|
+
const resUrl = response.url();
|
|
65
|
+
const resUrlLower = resUrl.toLowerCase();
|
|
66
|
+
if (resUrlLower.includes(keyword)) {
|
|
67
|
+
matches.push({
|
|
68
|
+
path: "response.url",
|
|
69
|
+
value: resUrl,
|
|
70
|
+
context: `url: ${highlightMatch(resUrl, keyword, CONTEXT_LENGTH_DEFAULT)}`,
|
|
71
|
+
source: "responseUrl",
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
else if (keywordPathOnly && resUrlLower.includes(keywordPathOnly)) {
|
|
75
|
+
matches.push({
|
|
76
|
+
path: "response.url",
|
|
77
|
+
value: resUrl,
|
|
78
|
+
context: `url: ${highlightMatch(resUrl, keywordPathOnly, CONTEXT_LENGTH_DEFAULT)}`,
|
|
79
|
+
source: "responseUrl",
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
try {
|
|
84
|
+
const u2 = new URL(resUrl);
|
|
85
|
+
const pathnameLower2 = u2.pathname.toLowerCase();
|
|
86
|
+
if (pathnameLower2.includes(keyword) ||
|
|
87
|
+
(keywordPathOnly && pathnameLower2.includes(keywordPathOnly)))
|
|
88
|
+
matches.push({
|
|
89
|
+
path: "response.url",
|
|
90
|
+
value: resUrl,
|
|
91
|
+
context: `url: ${highlightMatch(resUrl, keywordPathOnly || keyword, CONTEXT_LENGTH_DEFAULT)}`,
|
|
92
|
+
source: "responseUrl",
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
catch { }
|
|
96
|
+
}
|
|
97
|
+
if (keywordParams.length) {
|
|
98
|
+
try {
|
|
99
|
+
const u2 = new URL(resUrl);
|
|
100
|
+
for (const { name, value } of keywordParams) {
|
|
101
|
+
if (!name)
|
|
102
|
+
continue;
|
|
103
|
+
const pageVal = u2.searchParams.get(name);
|
|
104
|
+
if (!pageVal)
|
|
105
|
+
continue;
|
|
106
|
+
const valLower = (value || "").toLowerCase();
|
|
107
|
+
if (!valLower)
|
|
108
|
+
continue;
|
|
109
|
+
const pageValLower = pageVal.toLowerCase();
|
|
110
|
+
if (pageValLower.includes(valLower))
|
|
111
|
+
matches.push({
|
|
112
|
+
path: `response.url.query.${name}`,
|
|
113
|
+
value: pageVal,
|
|
114
|
+
context: `${name}=${highlightMatch(pageVal, value, CONTEXT_LENGTH_DEFAULT)}`,
|
|
115
|
+
source: "responseUrl",
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch { }
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch { }
|
|
124
|
+
};
|