簡體   English   中英

Chrome 擴展程序:“在 url 上沒有 cookies 的權限”

[英]Chrome extension: "No permission for cookies at url"

我嘗試從一個特殊的網站獲取 Cookies。

清單權限:

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

這是我的 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;

..但它只是告訴我,我沒有權限:

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 

你能告訴我我犯的錯誤嗎?......它讓我瘋狂。 謝謝你!

馬庫斯

Manifest 版本 3 對主機權限進行了一些更改。在 MV3 中,您需要將主機權限與其他權限分開指定:

// 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/",
  "*://*/*"
],

您的匹配模式格式錯誤。 您在主機名中的星號后缺少句點:

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

如果主機標識符帶有* ,則必須:

  • 是整個主機標識符,或者
  • 主機標識符的第一個字符,后跟一個句點。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM