Trivial Chrome pageAction extension not working -


i'm trying write trivial chrome pageaction extension change anchors on page 1 domain another... can't quite seem work, , i'm having trouble debugging it.

am misunderstanding how kind of extension needs built? or misusing api?

manifest.json:

{   "name": "theirs2ours",   "version": "1.0",   "description": "changes 'their' urls 'our' urls.",   "background_page": "background.html",   "permissions": [     "tabs"   ],   "page_action": {     "default_icon": "cookie.png",     "default_title": "theirs2ours"   },   "content_scripts": [     {       "matches": ["http://*/*"],       "js": ["content.js"]     }   ] } 

background.html:

<html> <head> <script type='text/javascript'>  chrome.tabs.onselectionchanged.addlistener(function(tabid) {   chrome.pageaction.show(tabid); });  chrome.tabs.getselected(null, function(tab) {   chrome.pageaction.show(tab.id); });  chrome.pageaction.onclicked.addlistener(function(tab) {     chrome.tabs.sendrequest(tab.id, {}, null); });  </script> </head> <body> </body> </html> 

content.js:

var transform = function() {   var theirs = 'http://www.yourdomain.com';   var ours = 'http://sf.ourdomain.com';   var anchors = document.getelementsbytagname('a');   (var in anchors) {     var link = anchors[a];     var href = link.href;     if (href.indexof('/') == 0) link.href = ours + href;     else if (href.indexof(theirs) == 0) link.href = href.replace(theirs, ours);   } };  chrome.extension.onrequest.addlistener(function(request, sender, sendresponse) {   transform(); }); 

you're not requesting permission run content scripts on these pages. matches content scripts determines pages executed in still need request permission inject scripts in these pages.

"permissions": [   "tabs",   "http://*/*" ] 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -