diff --git a/src/drivers/webextension/js/content.js b/src/drivers/webextension/js/content.js index d0209af65..63e387b51 100644 --- a/src/drivers/webextension/js/content.js +++ b/src/drivers/webextension/js/content.js @@ -171,6 +171,14 @@ const Content = { : resolve() )) + const cookies = document.cookie.split('; ').reduce( + (cookies, cookie) => ({ + ...cookies, + [cookie.split('=').shift()]: [cookie.split('=').pop()], + }), + {} + ) + // CSS rules let css = [] @@ -235,7 +243,7 @@ const Content = { } } - Content.cache = { html, css, scripts, meta } + Content.cache = { html, css, scripts, meta, cookies } await Content.driver('onContentLoad', [ url, diff --git a/src/drivers/webextension/js/driver.js b/src/drivers/webextension/js/driver.js index dfc22924f..df532b063 100644 --- a/src/drivers/webextension/js/driver.js +++ b/src/drivers/webextension/js/driver.js @@ -423,18 +423,15 @@ const Driver = { */ async onContentLoad(url, items, language, requires) { try { - const { hostname } = new URL(url) + items.cookies = items.cookies || {} - items.cookies = ( + // + ;( await promisify(chrome.cookies, 'getAll', { - domain: `.${hostname}`, + url, }) - ).reduce( - (cookies, { name, value }) => ({ - ...cookies, - [name.toLowerCase()]: [value], - }), - {} + ).forEach( + ({ name, value }) => (items.cookies[name.toLowerCase()] = [value]) ) await Driver.onDetect(