Skip to content

Commit ac0c45a

Browse files
andy380743909Andy
and
Andy
authored
fix: onBeforeRequest's filter function return wrong data type (#70)
see #64 (comment) see https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/onBeforeRequest Co-authored-by: Andy <[email protected]>
1 parent ee849c3 commit ac0c45a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

chrome/js/background.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,17 @@ chrome.webRequest.onHeadersReceived.addListener(
2525

2626
chrome.webRequest.onBeforeRequest.addListener(
2727
function (details) {
28-
if (tabinfo.get(details.tabId)) {
29-
return details.url;
30-
}
28+
// Comment out these lines
29+
// The returned data is NOT a webRequest.BlockingResponse type data, will cause error on Chrome Version 87 88 90
30+
// see https://github.com/justjavac/ReplaceGoogleCDN/issues/64#issuecomment-839610913
31+
// see https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/onBeforeRequest
32+
33+
// If we need to deal with the CSP, we must return the right data type but not simple a url string.
34+
35+
// if (tabinfo.get(details.tabId)) {
36+
// return details.url;
37+
// }
38+
3139
let url = details.url.replace('http://', 'https://')
3240
url = url.replace('ajax.googleapis.com', 'ajax.loli.net');
3341
url = url.replace('fonts.googleapis.com', 'fonts.loli.net');

0 commit comments

Comments
 (0)