1

The main idea is to put a website inside the extension, this website has scripts, but they are not running. All of the links are relative, even the options page scripts are not working.

<script>
   alert("a");
</script>

Am I missing something in the manifest.json file?

{
    "manifest_version": 2,
    "name": "Extension",
    "description": "This is an extension.",
    "version": "1.0",
    "background": {
        "scripts": ["background.js"]
    },
    "permissions": ["tabs" , "contextMenus"],
    "browser_action": {
        "default_icon": "icon.png"
    },
    "content_scripts": [
        {
            "matches": ["<all_urls>"],
            "js": ["./website/scripts/JvScripts.js"]
        }
    ],
    "options_page": "options.html"
}
3
  • 1
    See csp. Commented Jul 21, 2013 at 12:45
  • 1
    Are there any error messages from the dev tools? Commented Jul 21, 2013 at 13:02
  • Can it be that you have the <script> tag within your javascript file? Commented Jul 21, 2013 at 20:53

2 Answers 2

1

Your script should run fine. I have just set up a similar one on github.

On the option_page you have to link to the script you want to run in the html, it does not get injected. This is due to security.

In your options.html you will have to add:

<script src="relative/path/to/your/options.js"></script>

Do not forget to reload your extension every time you make a change to your script.

For simple changes you might find extension reloader useful, only bear in mind that you have to reload manually from the extension setting page when your manifest.json changes.

Sign up to request clarification or add additional context in comments.

2 Comments

i'm really really really sure that i linked the scripts correctly, i told you that i just wrote a script for "alert" and it didn't worked .... as for "js": ["website/scripts/JvScripts.js"] i've tried also and it didn't work ..
@AmbiguousTk See my example github extension on github.com/k0pernikus/stackoverflowQuestion17772418
0

Endeavor to remove the script tag from your javascript file. I do believe that would help

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.