Friday, May 10, 2024
44
rated 0 times [  45] [ 1]  / answers: 1 / hits: 27199  / 12 Years ago, wed, july 18, 2012, 12:00:00

I am trying to make basically an element highlighter chrome extension.
Workflow:
- click on browser icon
- click on the page
- hightlight the element clicked



I am having troubles in running content scripts upon browser action using manifest_version:2
When I inspect the popup that appears it says:




Refused to execute inline script because it violates the following
Content Security Policy directive: script-src 'self'
chrome-extension-resource: (popup.html:5).




Which is where the inline script in popup.html is and the script does not work



I have:



manifest.json:



{
browser_action: {
default_icon: images/icon.gif,
default_popup: popup.html
},
manifest_version: 2,
description: MEH!,
name: My First Extension,
permissions: [
tabs, http://*/*, https://*/*
],
version: 0.1
}


popup.html:



<html>
<head>
</head>
<body>
<script>
chrome.tabs.executeScript(null,{
code:document.body.style.backgroundColor='red'
});
</script>
<div id='msg' style=width:300px>...</div>
</body>
</html>


Any help would be very much appreciated


More From » google-chrome-extension

 Answers
6

Turns out I could not read the error properly until I saw it in here



Apparently manifest v2 does not allow you to have inline scripts, so you just need to



src=path_to_the_file.js

[#84172] Tuesday, July 17, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kylee

Total Points: 60
Total Questions: 119
Total Answers: 101

Location: Bonaire
Member since Wed, Mar 29, 2023
1 Year ago
;