Fix cookie detection in WebExtension driver

main
Elbert Alias 3 years ago
parent 360da3853e
commit ed8a32f177

@ -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,

@ -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(