首页 > 解决方案 > chrome.cookies.set 不在隐身窗口中创建 cookie

问题描述

我正在尝试创建 Chrome 扩展来管理 cookie 我为此创建了这个简单的代码

清单.json

{
    "name" : "cookie_tester",
    "version" : "0.1",
    "description" : "Tool for cookie mechanism",
    "permissions": [ "cookies", "tabs", "activeTab", "storage", "<all_urls>"],
        "icons": { 
            "128": "icon.png" 
            },

    "page_action": {
      "default_icon": {
            "128": "icon.png" 
      },
      "default_title":"cookie_tester"      
    },


    "background": {
    "scripts": ["background.js"],
    "persistent": false
    },
    "manifest_version": 2
}

background.js 在这里https://pastebin.com/raw/YpQRqvZr

因此,当我激活隐身窗口并单击扩展图标时:未创建 cookie。 未创建 cookie

当然我已经允许这个扩展在隐身模式下工作 允许隐身模式 你能帮我找出原因吗?Chrome 版本是版本 71.0.3578.80 (Official Build) (64-bit) 在此先感谢

标签: google-chromecookiesgoogle-chrome-extension

解决方案


谢谢@wOxxOm 是的,当我将隐身键添加到具有值“split”的mainfest 中时,我终于得到了工作结果!

更新 manifest.js

{
  "name" : "cookie_tester",
  "version" : "0.1",
  "description" : "Tool for cookie mechanism ",
  "permissions": [ "cookies", "tabs", "activeTab", "storage", "<all_urls>"],
  "icons": { 
                "128": "icon.png" 
                },

        "page_action": {
          "default_icon": {
                "128": "icon.png" 
          },
          "default_title":"cookie_tester"      
        },


  "background": {
    "scripts": ["background.js"],
    "persistent": false
  },

  "manifest_version": 2,
  "incognito": "split"
}

推荐阅读