0

I would like to import my cookies for a specific website from Safari to Chrome. I am currently following this answer. The main problem I'm having is I do not know how to indicate which cookies I would like to import.

So far, my manifest.json file looks like this:

{
  "name": "CookieImport",
  "version": "0.0.0",
  "permissions": [
    "cookies",
    "*://*.armorgames.com/*"
  ],
  "options_page": "options.html",
  "manifest_version": 2
}

My options.html file looks like this:

<!doctype html>
<html>
    <head></head>
    <body>
        <script src="options.js"></script>
    </body>
</html>

And my options.js file looks like this:

const allCookies = [
    {
        url: "https://armorgames.com",
        name: "__foo",
        value: "bar",
        domain: ".armorgames.com",
        // see all possible fields at:
        // https://developer.chrome.com/extensions/cookies#method-set
    },
    // ... more cookies here
];

const button = document.createElement("button"); button.type = "button"; document.body.appendChild(button); button.textContent = "Import Cookies"; button.addEventListener("click", () => { for (const c of allCookies) { chrome.cookies.set(c, (res) => { console.log("set", c, res || chrome.runtime.lastError); }); } });

After doing loading this to Chrome as an unpacked extension and using the Import Cookies button, there was no change.

I'm aware I can't leave the name and value portion of the options.js file as foo and bar, but what would I put there to specify which cookies to grab?

Also, I've tried leaving out the name and value parts in hope that it would grab everything from the specified domain; this did not work.

2 Answers2

0

This method used to work:

  • In Safari under the file menu select Export Bookmarks

  • Choose an appropriate location to store the file, and click Save

  • Launch Google Chrome

  • In the three-dots menu, select Bookmarks > Bookmark Manager

  • In the lower three-dots menu, select Import Bookmarks

  • Navigate to the file you saved from Safari and select Open.

harrymc
  • 498,455
-1

I remember using the same method as Harry mentioned above way back, not sure if it's still the right way.

I did it recently with bookmarks by simple exporting the html file and adding it to my new browser, but im honestly not sure if it works the same way with cookies.