Skip to main content

Posts

Showing posts with the label google-chrome-extension

How can a Chrome extension's content script determine the injected page's referrer?

What is the best way to determine a page's referrer within the context of a content script in a Chrome extension? It looks possible to intercept requests' headers using the chrome.webRequest module, but it would then take some book-keeping and message-passing in order to get it into the content script. That approach feels kludgy. Is there a better way?

Open new tab in Chrome extensions

I'm trying to write a simple google extension that will upon clicking "ctrl+alt+x" search for the selected text in google. This is my mainfest: { "name": "A jQuery Chrome extension", "version": "0.1", "description": "Use jQuery to build Chrome extensions", "content_scripts": [ { "matches" : ["http://*/*"], "js": ["jquery.js", "jquery.hotkeys.js", "content.js"] } ], "background_page": "background.html", "permissions": [ "tabs" ] } And this is my content.js: $(document).bind('keydown', 'alt+ctrl+x', function() { var selectedText = window.getSelection().toString(); if (selectedText) { var googleQuery = "http://www.google.com/search?q=" + selectedText; alert(googleQuery); chrome.tabs.create({"url