Skip to content

Commit

Permalink
#7 Firefox fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
badsgahhl committed May 25, 2020
1 parent 8673521 commit d68a47c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"http://*/*",
"https://*/*",
"webRequest",
"webRequestBlocking"
"webRequestBlocking",
"activeTab"
]
}
1 change: 1 addition & 0 deletions src/module/popup/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
body {
min-width: 150px;
max-width: 190px;
overflow: hidden; /* Hide scrollbars */
}

#main {
Expand Down
27 changes: 17 additions & 10 deletions src/module/popup/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,19 @@ async function list_domain(mode: ApiListMode, buttonElement: HTMLButtonElement):
}

// Registering the handler only after the button click. We dont want to change the headers of anything else
chrome.webRequest.onBeforeSendHeaders.addListener(
get_web_request_origin_modifier_callback, {
urls: [pi_url + "/*"]
},
[
"blocking",
"requestHeaders",
"extraHeaders"
]);
// This is only needed in chrome!
if (typeof browser === 'undefined')
{
chrome.webRequest.onBeforeSendHeaders.addListener(
get_web_request_origin_modifier_callback, {
urls: [pi_url + "/*"]
},
[
"blocking",
"requestHeaders",
"extraHeaders"
]);
}

toggle_list_button(buttonElement);

Expand All @@ -230,7 +234,10 @@ async function list_domain(mode: ApiListMode, buttonElement: HTMLButtonElement):
api_request.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200)
{
chrome.webRequest.onBeforeSendHeaders.removeListener(get_web_request_origin_modifier_callback);
if (typeof browser === 'undefined')
{
chrome.webRequest.onBeforeSendHeaders.removeListener(get_web_request_origin_modifier_callback);
}
// We wait 12 Seconds until we can assume that the pihole is back online.
setTimeout(() => toggle_list_button(buttonElement), 12000);
}
Expand Down

0 comments on commit d68a47c

Please sign in to comment.