1

I try to get Cookies from a special Website.

Manifest permissions:

"permissions": [
"tabs",
"*//*free-way.me",
"storage",
 "cookies"
],

And this is my popup.js:

function getCookies(domain, name) 
{
    chrome.cookies.get({"url": domain, "name": name}, function(cookie) {
        return cookie.value;

    });
}

var uid = getCookies("http://.free-way.me", "uid")     
var upw = getCookies("http://.free-way.me", "upw")     

document.getElementById("user").value = uid;
document.getElementById("pw").value = upw;

..but it's just telling me, that I'd no permissions:

cookies.get: No host permissions for cookies at url: "http://.free-way.me/".
at getCookies (chrome-extension://[...]/popup.js:19:24)
at chrome-extension://[...]/popup.js:25:13 

Can you tell me please my mistake I made?...It drives me cracy. Thank you!

Markus

Standard
  • 1,450
  • 17
  • 35

2 Answers2

2

some change have been taken place in Manifest version 3 about host permission.In MV3, you'll need to specify host permissions separately from other permissions:

// Manifest V2
"permissions": [
  "tabs",
  "bookmarks",
  "http://www.blogger.com/",
],
"optional_permissions": [
  "*://*/*",
  "unlimitedStorage"
]

 // Manifest V3
"permissions": [
  "tabs",
  "bookmarks"
],
"optional_permissions": [
  "unlimitedStorage"
],
"host_permissions": [
  "http://www.blogger.com/",
  "*://*/*"
],
0

Your match pattern is malformed. You're missing a period after the asterisk in the host name:

"*//*.free-way.me"

If the host identifier has a *, it must either:

  • be the entire host identifier, or
  • be the first character of the host identifier and be followed immediately by a period.
apsillers
  • 112,806
  • 17
  • 235
  • 239
  • Thank you, but it still gives me the same error.. and btw, the domainname in the cookie is named ".free-way.me". Is my requested URL correct? Thanks mate! – Standard Oct 01 '13 at 19:21
  • 1
    @wernersbacher You also are misusing the asynchronous extension APIs. See the "Restructure code" section in [How to return the response from an AJAX call?](http://stackoverflow.com/q/14220321/710446) for an overview of how to use asynchronous callback functions. (That shouldn't give you a cookie-error, but it will stop your code from working.) – apsillers Oct 01 '13 at 19:28
  • @wernersbacher Have you tried removing the leading period and just asking for `free-way.me`? I've never used the cookies API myself, and the documentation is a bit sparse, so I'm not sure. – apsillers Oct 01 '13 at 19:31
  • Yes, I tried nearly every possibility, but it didn't work. Now I got a Callback Function, even if I don't really understand it. I used this one: [link]http://stackoverflow.com/questions/5892176/getting-cookies-in-a-google-chrome-extension Thank you @apsillers – Standard Oct 01 '13 at 19:46
  • I forgot to say that it works fine now. Thank you for your help. Have a good night! – Standard Oct 01 '13 at 19:59
  • @wernersbacher How did you fix the issue with the starting point? I cant delete them... – Esteban Jun 13 '21 at 13:45
  • @Esteban Sorry, I don't know anymore, and I can't find the sources of this project anymore. :/ – Standard Jun 15 '21 at 07:14