0

I'm stuck with what seems to be really simple. I'm trying to inject a div of my own in every page the user visited, in a google chrome extention. I looked at examples on the web, but nothing seems to be working with me :s

Here's my manifest.json

{
"name": "My extension",
"version": "1.0",
"permissions": [
 "http://*/*", "tabs", "https://*/*"
],
"browser_action": {
 "default_title": "My extension",
 "default_icon": "icon.png"
},
"manifest_version": 2,
"content_scripts": [
 {
 "matches": ["http://*/*", "https://*/*"],
 "js": ["test.js"],
 "run_at": "document_end",
 "all_frames": true
 }
]
}

And my test.js

var newdiv = document.createElement('div'); 
newdiv.setAttribute('id','this_is_my_own_div');
document.body.appendChild(newdiv);

But I get nothing in source codes... My div's not created. How can I check if my test.js is running ? I can't understand why it is working with others and not with me :s Any help appreciate !

asked Nov 15, 2012 at 10:35

1 Answer 1

2

It worked try:

"browser_action": { "default_title": "My extension", "default_icon": "icon.png" },

instead of:

"browser_action": { "name": "My extension", "icons": ["icon.png"] }, 
Brock Adams
94k23 gold badges242 silver badges312 bronze badges
answered Nov 15, 2012 at 10:44
Sign up to request clarification or add additional context in comments.

3 Comments

It worked try "browser_action": { "default_title": "My extension", "default_icon": "icon.png" }, instead of "browser_action": { "name": "My extension", "icons": ["icon.png"] },
I might be missing someting here... That doesn't work either. Stil no "this_is_my_own_div" in the source page of amazon.com for example...
Hmm, apparently, it's working on my colleague's Mac. I run Version 23.0.1271.64 m on Windows 8, maybe this is why... Strange though...

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.