diff --git a/src/background.js b/src/background.js index 2052b99..c9ac546 100644 --- a/src/background.js +++ b/src/background.js @@ -44,6 +44,7 @@ const cookieListener = (changeInfo) => { if (removed) { AccessToken.destroy(); + return; } AccessToken.set(cookie.value); @@ -81,6 +82,21 @@ async function start() { requestHeaders, }; }, { urls: [`${SERP_BASE_URL}/search*`]}, ["blocking", "requestHeaders"]); + + browser.webRequest.onBeforeSendHeaders.addListener(async (details) => { + const { requestHeaders } = details; + const accessToken = AccessToken.get(); + if (!accessToken) { + return; + } + requestHeaders.push({ + name: "Authorization", + value: `Bearer ${accessToken}`, + }); + return { + requestHeaders, + }; + }, { urls: [`${SERP_BASE_URL}/login*`]}, ["blocking", "requestHeaders"]); } start(); \ No newline at end of file diff --git a/src/config.js b/src/config.js index c9ccf18..cc701cc 100644 --- a/src/config.js +++ b/src/config.js @@ -1,3 +1,3 @@ -let DEBUG = false; +let DEBUG = true; let API_BASE_URL = DEBUG ? 'http://localhost:5000' : 'https://ghosterysearch.com'; let SERP_BASE_URL = DEBUG ? 'http://localhost' : 'https://ghosterysearch.com'; diff --git a/src/manifest.json b/src/manifest.json index 3eeb82e..6725690 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,5 +1,5 @@ { - "version": "0.1.3", + "version": "0.1.4", "browser_specific_settings": { "gecko": { "id": "search@ghostery.com"