Friday 25 February 2022

browser.cookies.getAll() always returns nothing - Firefox Extension

I have been trying to list all browser cookies in my extension with browser.cookies.getAll(). At first I thought it was a permissions issue, but my permissions appear to be set correctly. Here is my code:

manifest.json

{
    "manifest_version": 2,
    "name": "CookieExample",
    "version": "0.1",

    "applications": {
        "gecko": {
            "id": "cookieexample@example.com"
        }
    },

    "permissions": [
        "cookies",
        "webNavigation",
        "webRequest",
        "webRequestBlocking",
        "<all_urls>"
    ],

    "background": {
        "scripts": ["cookies.js"]
    }        
}

cookies.js

browser.cookies.getAll({}, function(cookies) {
    console.log(cookies);
});

The console simply logs [] as the return value. I don't know where I've gone wrong or if it's a problem with the browser. Cookie Manager works just fine and lists all browser cookies without a hitch. Looking into its source code, the only difference is that it uses a cookie store ID to query for cookies, whereas I used nothing.



from browser.cookies.getAll() always returns nothing - Firefox Extension

No comments:

Post a Comment