6 ms·
I have a Greasemonkey script in FF (http://defcraft.blogspot.com/2009/02/greasemonkey-search-helper.html http://defcraft.blogspot.com/2009/02/greasemonkey-searc
by sri 17y ago
I have a Greasemonkey script in FF (http://defcraft.blogspot.com/2009/02/greasemonkey-search-helper.html http://defcraft.blogspot.com/2009/02/greasemonkey-search-hel...) that'll google for the current selection in a background tab when ALT-G is pressed. And it uses GM_openInTab API call.
Its equivalent in Chrome seems to be chrome.tabs.create. But when I tried that, I get this error: "chrome.tabs is not supported in content scripts". It seems that these "content scripts" aren't as powerful as extensions (http://code.google.com/chrome/extensions/content_scripts.html http://code.google.com/chrome/extensions/content_scripts.htm...). Am I missing something here?
- joeyo 17y agoI realize that this doesn't exactly address the root cause of your issue, but if you right click on selected text in Chrome, one of the menu entries will be to google for it in another tab.
- statictype 17y agoYes. Chrome has different ways of extending the browser. One is content scripts - which don't have access to certain parts of the Chrome api like opening tabs. However, each extension can have what they call a background page. This is just an html page which is loaded in the background and there can be exactly one for every extension. So you should be able to have your content script communicate with the background page (there is a mechanism for this) and let the background page open the tab. For this, you'll have to write a fully-fledged extension though. The greasemonkey scripts probably don't generate a background page when they get converted into an extension at install-time.