Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/455.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 当我尝试单击函数时,Chrome扩展出现错误_Javascript_Html_Json_Google Chrome Extension - Fatal编程技术网

Javascript 当我尝试单击函数时,Chrome扩展出现错误

Javascript 当我尝试单击函数时,Chrome扩展出现错误,javascript,html,json,google-chrome-extension,Javascript,Html,Json,Google Chrome Extension,我有一个chrome扩展,它可以执行以下操作:尝试添加一个指向google chrome存储的链接,这样我就可以获得该链接,并将其添加到我的html中。当我进行一些调试时,我注意到当我单击我的按钮add链接时,它的href为javascript:getStorage 完整HTML 清单 { "manifest_version": 2, "web_accessible_resources": [ "popup.html"

我有一个chrome扩展,它可以执行以下操作:尝试添加一个指向google chrome存储的链接,这样我就可以获得该链接,并将其添加到我的html中。当我进行一些调试时,我注意到当我单击我的按钮add链接时,它的href为
javascript:getStorage

完整HTML

清单

{
  "manifest_version": 2,

  "web_accessible_resources": [
    "popup.html", "popup.js"
  ],

  "name": "UrlManager",
  "description": "Quickly open urls.",
  "version": "1.0.1",
  
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["popup.js"]
    }
  ],

  "permissions": [
    "tabs", 
    "storage", 
    "unlimitedStorage"
  ],

  "browser_action": {
      "default_icon": "icon.png",
      "default_popup": "popup.html",
      "default_title": "Open a URL"
  }
}
有没有办法解决这个问题

Refused to run the JavaScript URL because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem:". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.

{
  "manifest_version": 2,

  "web_accessible_resources": [
    "popup.html", "popup.js"
  ],

  "name": "UrlManager",
  "description": "Quickly open urls.",
  "version": "1.0.1",
  
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["popup.js"]
    }
  ],

  "permissions": [
    "tabs", 
    "storage", 
    "unlimitedStorage"
  ],

  "browser_action": {
      "default_icon": "icon.png",
      "default_popup": "popup.html",
      "default_title": "Open a URL"
  }
}
var storage = chrome.storage.local;

function setStorage() {
    var value = prompt("Whats your link")
    
    storage.set({key: value}, function() {
        console.log('Value is set to ' + value);
    });
}

 
function getStorage() {
    storage.get(['key'], function(result) {
        console.log('Value currently is ' + result.key);
    });
}