Skip to content

Commit

Permalink
Version 1.0.10. Firefox fix for "extraHeaders".
Browse files Browse the repository at this point in the history
  • Loading branch information
kickscondor committed May 29, 2021
1 parent bcd4a54 commit a5480cf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"repository": {
"url": "https://github.com/kickscondor/fraidycat"
},
"version": "1.1.9",
"version": "1.1.10",
"scripts": {
"start": "npm run electron:setup && electron .",
"start:firefox": "web-ext run --source-dir ./build/webext/",
Expand Down Expand Up @@ -103,6 +103,6 @@
"parcel-plugin-web-extension": "^1.6.1",
"sass": "^1.32.8",
"web-ext": "^4.3.0",
"webextension-polyfill": "^0.6.0"
"webextension-polyfill": "^0.8.0"
}
}
13 changes: 11 additions & 2 deletions src/js/webext/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class WebextStorage {
browser.webRequest.onBeforeSendHeaders.addListener(rewriteUserAgentHeader,
{urls: ["<all_urls>"], types: ["xmlhttprequest"]}, ["blocking", "requestHeaders"])

browser.webRequest.onHeadersReceived.addListener(e => {
let headersRecvFn = e => {
let initiator = e.initiator || e.originUrl
let headers = e.responseHeaders
if (e.tabId === -1 && initiator && extUrl && (initiator + "/").startsWith(extUrl)) {
Expand All @@ -288,7 +288,16 @@ class WebextStorage {
}
}
return {responseHeaders: headers};
}, {urls: ["<all_urls>"]}, ["blocking", "responseHeaders", "extraHeaders"])
}

// Firefox throws an error on "extraHeaders"
try {
browser.webRequest.onHeadersReceived.addListener(headersRecvFn,
{urls: ["<all_urls>"]}, ["blocking", "responseHeaders", "extraHeaders"])
} catch {
browser.webRequest.onHeadersReceived.addListener(headersRecvFn,
{urls: ["<all_urls>"]}, ["blocking", "responseHeaders"])
}

browser.webRequest.onCompleted.addListener(async e => {
let headers = e.responseHeaders
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Fraidycat",
"short_name": "Fraidycat",
"key": "hecfkgekabkkhiidlinmifelhdooeool",
"version": "1.1.9",
"version": "1.1.10",
"description": "Follow from afar.",
"homepage_url": "https://fraidyc.at/",
"icons": {
Expand Down

0 comments on commit a5480cf

Please sign in to comment.