Let me preface this with saying I have read and tried everything on this site about this so far.
I am trying to make a Google Chrome extension that needs to get some selected text from a page. I know that I cannot do this inline in my popup.html, so my first thought was to break it out into a JS file. When I tried to do this, I was not able to use any functions like getElementById
. They just didn't work. I tried all the permissions, different variations on the function, and it appeared as though Chrome was sand boxing the files.
My next attempt was to enable inline with CSP. I am getting error messages like this one:
'content_security_policy': Ignored insecure CSP value
"'sha256-08fd8a0180576c8bf2b8652419b5b8f4820513e2cbc085c0335c665cfeabb190''sha256-0c57eb1c87ec4157d3551f15681b726e5aadd64b969c331b24ce8ce6df548005'"
in directive 'script-src'
and I am not sure the issue or how to fix it.
I just want to know if and how to enable inline with CSP, or if anyone has any ideas about how to get the selection to a variable that I can use
My Manifest.json:
{
"name": "FirstUse",
"version": "1.0",
"description": "Find the First Use of something!",
"browser_action":{
"default_popup": "popup.html",
"default_icon": "icon.png"
},
"permissions": ["storage", "contextMenus", "activeTab", "tabs", "clipboardWrite", "clipboardRead"],
"content_security_policy": "script-src 'self' 'sha256-08fd8a0180576c8bf2b8652419b5b8f4820513e2cbc085c0335c665cfeabb190''sha256-0c57eb1c87ec4157d3551f15681b726e5aadd64b969c331b24ce8ce6df548005'",
"background": {
"scripts": ["background.js", "popup.html"],
"persistent": true
},
"manifest_version": 2
}