diff --git a/plugin/js/HttpClient.js b/plugin/js/HttpClient.js index 3f40b0b1..0f980905 100644 --- a/plugin/js/HttpClient.js +++ b/plugin/js/HttpClient.js @@ -207,33 +207,35 @@ class HttpClient { } static async setPartitionCookies(url) { - if (!util.isFirefox()) { - // get partitionKey in the form of https://. - let parsedUrl = new URL(url); + // get partitionKey in the form of https://. + let parsedUrl = new URL(url); + //keep old code for reference in case it changes again + //let topLevelSite = parsedUrl.protocol + "//" + parsedUrl.hostname; + + try { + // get all cookie from the site which use the partitionKey (e.g. cloudflare) //keep old code for reference in case it changes again - //let topLevelSite = parsedUrl.protocol + "//" + parsedUrl.hostname; - - try { - // get all cookie from the site which use the partitionKey (e.g. cloudflare) - //keep old code for reference in case it changes again - //let cookies = await chrome.cookies.getAll({partitionKey: {topLevelSite: topLevelSite}}); - - //set domain to the highest level from the website as all subdomains are included #1447 #1445 - let urlparts = parsedUrl.hostname.split("."); - let cookies = await chrome.cookies.getAll({domain: urlparts[urlparts.length-2]+"."+urlparts[urlparts.length-1],partitionKey: {}}); - - //create new cookies for the site without the partitionKey - //cookies without the partitionKey get sent with fetch - cookies.forEach(element => chrome.cookies.set({ - domain: element.domain, - url: "https://"+element.domain.substring(1), - name: element.name, - value: element.value - })); - } catch { - // Probably running browser that doesn't support partitionKey, e.g. Kiwi - } - } + //let cookies = await chrome.cookies.getAll({partitionKey: {topLevelSite: topLevelSite}}); + + //set domain to the highest level from the website as all subdomains are included #1447 #1445 + let urlparts = parsedUrl.hostname.split("."); + let cookies = ""; + if (!util.isFirefox()) { + cookies = await chrome.cookies.getAll({domain: urlparts[urlparts.length-2]+"."+urlparts[urlparts.length-1],partitionKey: {}}); + }else{ + cookies = await browser.cookies.getAll({domain: urlparts[urlparts.length-2]+"."+urlparts[urlparts.length-1],partitionKey: {}}); + } + //create new cookies for the site without the partitionKey + //cookies without the partitionKey get sent with fetch + cookies.forEach(element => chrome.cookies.set({ + domain: element.domain, + url: "https://"+element.domain.substring(1), + name: element.name, + value: element.value + })); + } catch { + // Probably running browser that doesn't support partitionKey, e.g. Kiwi + } } }