0

I'm having trouble getting a simple google extension to work. The manifest file looks like this:

{
 "background": {"scripts": ["background.js"]},
 "browser_action": {
 "default_icon": "icon-128.png",
 "default_title": "Lookup"
 },
 "name": "Lookup",
 "description": "Does stuff",
 "homepage_url": "http://www.artifacting.com",
 "icons": {
     "16": "icon-16.png",
     "48": "icon-48.png",
     "128": "icon-128.png" },
 "permissions": [
     "tabs",
     "http://*/*",
     "https://*/*"
 ],
 "version": "0.1",
 "manifest_version": 2
}

my background.js simply points to my bookmarklet.js

background.js:

chrome.browserAction.onClicked.addListener(function(tab) {
    chrome.tabs.executeScript(tab.id, {file: "bookmarklet.js"})
});

bookmarklet.js

setTimeout('x99.focus()',300);var re=/([/-]|li[er]n=)(d{2,3}[dX])/i;if(re.test(location.href)==true){var isbn=RegExp.$2;var x99=window.open('http://catalog.mywebsite.org/search/searchresults.aspx?ctx=1.1033.0.0.6&type=Keyword&term='+lookup,'Lookup','scrollbars=1,resizable=1,top=0,left=0,location=1,width=800,height=600');x99.focus();}

I'm unsure why when i click on the extension an new window isn't opening up. I'm pretty sure that the setTimeout command isn't working with the chrome exstensions but I'm not sure how to rewrite it correctly. Thanks for your help.

hubs
  • 25
  • 3

1 Answers1

-1

setTimeout works just fine with both injected scripts and background page. You bookmarklet.js is not correct or not complete. It shows error: Uncaught TypeError: Cannot call method 'focus' of undefined Anyway check webpage and background page consoles for errors first. This saves you a lot of time

Yeldar Kurmangaliyev
  • 33,467
  • 12
  • 59
  • 101
Andrey
  • 722
  • 2
  • 8
  • 17