Skip to content

Commit 64c6012

Browse files
authored
Changed to use $WPT-BODIES
1 parent 6e45fe6 commit 64c6012

File tree

1 file changed

+7
-62
lines changed

1 file changed

+7
-62
lines changed

dist/exposed_keys.js

Lines changed: 7 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -75,62 +75,12 @@ const keyMap = {
7575
zohocrm: '\\b(1000\\.[a-f0-9]{32}\\.[a-f0-9]{32})\\b'
7676
};
7777
const scripts = Array.from(document.scripts);
78-
function fetchWithTimeout(url) {
79-
var controller = new AbortController();
80-
setTimeout(() => {controller.abort()}, 5000);
81-
return fetch(url, {signal: controller.signal});
82-
}
83-
84-
function parseResponse(url, parser) {
85-
return fetchWithTimeout(url)
86-
.then(request => {
87-
let resultObj = {};
88-
if(!request.redirected && request.status === 200) {
89-
resultObj['found'] = true;
90-
if(parser) {
91-
let promise = parser(request);
92-
if (promise) {
93-
return promise
94-
.then(data => {
95-
resultObj['data'] = data;
96-
return [url, resultObj];
97-
})
98-
.catch(error => {
99-
return [url, {'error': error.message}];
100-
});
101-
} else {
102-
resultObj['error'] = 'parser did not return a promise';
103-
return [url, resultObj];
104-
}
105-
} else {
106-
return [url, resultObj];
107-
}
108-
} else {
109-
resultObj['found'] = false;
110-
return [url, resultObj];
111-
}
112-
})
113-
.catch(error => {
114-
return [url, {'error': error.message}];
115-
});
116-
}
117-
118-
return Promise.all(
119-
scripts.map(script => {
120-
if (script.src) {
121-
return parseResponse(script.src, response => response.text());
122-
} else {
123-
return Promise.resolve(script.textContent.trim());
124-
}
125-
})
126-
).then((all_data) => {
127-
const combinedScripts = all_data.reduce((acc, data) => {
128-
if (Array.isArray(data)) {
129-
return acc + data[1].data + '\n';
130-
} else {
131-
return acc + data;
132-
}
133-
}, '');
78+
let requests = $WPT_BODIES;
79+
const combinedScripts = scripts
80+
.filter(script => !script.src)
81+
.map(script => script.textContent)
82+
.concat(requests.filter(request => request.type === 'Script').map(request => request.response_body))
83+
.join('\n');
13484

13585
const matched_keys = [];
13686
for (const [provider, pattern] of Object.entries(keyMap)) {
@@ -139,9 +89,4 @@ return Promise.all(
13989
matched_keys.push(provider);
14090
}
14191
}
142-
143-
return matched_keys;
144-
}).catch(error => {
145-
return JSON.stringify({ message: error.message, error });
146-
});
147-
92+
return matched_keys;

0 commit comments

Comments
 (0)