chrome.cookies.set不会在隐身窗口中创建Cookie

时间:2018-12-12 06:12:41

标签: google-chrome cookies google-chrome-extension

我正在尝试创建用于管理Cookie的Chrome扩展程序 我为此创建了这个简单的代码

manifest.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 wasn't created

我当然已经允许此扩展程序在隐身模式下工作 allow in incognito 您能帮我找出原因吗? Chrome版本为Version Version 71.0.3578.80(Official Build)(64位) 预先感谢

1 个答案:

答案 0 :(得分:0)

感谢@wOxxOm 是的,当我将隐身密钥添加到mainfest中并带有值“ split”时,我终于有了工作结果!

更新了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"
}