I want to develop an extension, which can detect what I typed words in address bar. If the words match something, it will show the specified url in address bar.
Actually, it's like as Google Chrome did by itself. But I will let the browser detect my keyword firstly, and show the specified url. Only when can't match my keywords, then show the url google provided.
I'm not sure it matches exactly what you need, but you can have a look at the Omnibox API:
When the user enters your extension's keyword, the user starts interacting solely with your extension. Each keystroke is sent to your extension, and you can provide suggestions in response.
The suggestions can be richly formatted in a variety of ways. When the user accepts a suggestion, your extension is notified and can take action.
This is not possible, but you could create your own address bar in HTML and monitor it for changes.
When users type a keyword, you could modify the window.location in another window. You could also modify the same window to show the url contents in an IFrame for instance.
Related
So using the Google Chrome Top Sites api has values for the url and the title, but when you load the default google chrome page it also has an image of those sites, is there any way to get that sort of image for an extension? If not how does google get that image and how can you get an image of the the user's top viewed website?
Since that it isn't possible to get a screenshot of a page without loading it inside a tab, Chrome is simply getting those screenshots while you're browsing your favourite sites. You can tell this easily because sometimes sites and images do not coincide (e.g. sometimes my facebook.com top site has the image of my profile page, but links to the home).
Then, if you want your screenshots of the Top Sites, you'll have to start without screenshots, and create them while the user browses the web by using the chrome.tabs API to check when a tab loads one of the Top Sites (listening to the event onUpdated), and get a screenshot of that tab using captureVisibleTab.
NOTES: make sure that you've requested the permission for "<all_urls>" in your manifest, which is required for captureVisibleTab to work. Additionally, you may find this question and its answer helpful.
It's unfortunately not possible*. Chrome stores those thumbnails internally in URIs not accessible from an extension.
There is an existing feature request: https://code.google.com/p/chromium/issues/detail?id=11854
If you look at the comments, one of the main use cases is to access site thumbnails to replicate the New Tab page.
Do star the feature request above to raise its priority if you want this functionality implemented.
* By that I mean that it's not possilbe to access Chrome's own internal store of thumbnails.
Furthermore, as Marco suggested the way to replicate that would be tab capture, but you can't do it "in the background" for privacy reasons - a user must make an explicit gesture (e.g. click the extension's button, press a shortcut, etc.) to perform capture.
Marco's answer is valid now, captureVisibleTab should be accessible upon events. But yes, as of now Chrome forces you to have very broad permissions and maintaining your own thumbnail store.
If I have a Google Apps Script that does some processing to a single gmail message, how can I trigger it from the gmail web interface so it gets applied to the message I have currently open on screen?
The closest way I've found is to apply a label and have a background process monitoring labels. Is there a way to add a button or menu option to gmail instead?
Thanks
No, there isn't. At least not using any "native" Apps Script or Gmail feature. You'd have to write a browser extension to achieve this.
Another thing you could do (aside from the special label) is to gmail's URL (while viewing the message) and paste it in your Apps Script interface (previously opened in another tab). Then your script can extract the message id from the URL and work on it right away.
Also, you could do something clever like having your script receive the id (or full gmail url) from a parameter on the script's own url, e.g. https://script.google.com/macros/s/<your-script-key>/exec?gmail=<url>
Then set up your browser (I know Chrome and Firefox do this) to trigger your script and pass the parameter based on a keyword in the location bar. I use mostly just one letter (like "y script" searches the word "script" on youtube. If you use for example "a", you could hit ctrl+L (select location bar), ctrl+c (copies gmail url), ctrl+t (new tab), then type "a ", ctrl+v, enter. Not exactly clicking a button on the gmail's interface, but does the job rather easily. If you're inclined to keyboard shortcuts like I am, this is even a preferable way :)
Another options is to label your message with some label and have an app script scan for this label every X minutes and process all messages it finds.
I was thinking of using the tabid to do this, but it seems to change quite often as I am browsing around within the tab. The API reference notes that the tabid is unique within a "browser session". I took this to mean within the lifetime of the browser process, but it seems more likely now that uniqueness is only guaranteed during a session with a specific website. Is there another way I could uniquely identify a tab for its entire life?
Due to prerendering and other factors, tabs can be 'replaced'. This means that tabId can change even if you keep the tab open. chrome.webNavigation.onTabReplaced can be used to capture such events. See https://developer.chrome.com/extensions/webNavigation.html#event-onTabReplaced for more information.
To demonstrate this, following these steps may help:
Make sure that you've requested "tabs" and "webNavigation" request for your extension and your extension doesn't use a non-persistent background page (without background.persistent = true in manifest.json). Also make sure Google is your default search engine and Instant Search is enabled.
Open some website (not Google search).
Execute chrome.tabs.query({}, function(tabs){console.log(tabs)}) in the developer tools of your extension's background page. Look at existing tabs and their ids.
Execute chrome.webNavigation.onTabReplaced.addListener(function(details){console.log(details); in the DevTools.
Type something in the omnibox of that tab to trigger Google Instant and click on the body of the page. You should see the onTabReplaced event fired and the old and new tab ids in the console of the DevTools.
Execute chrome.tabs.query({}, function(tabs){console.log(tabs)}) again and you'll find that tab id actually 'changed'.
I came to know that crossrider.com is helping us to develop extension for different browsers, while keeping the same code.
I have two questions
Question 1:
After going through docs and libraries in crossrider, I still wonder how to get the active tab url.
Question 2:
I also need to open a popup after clicking toolbar icon, similar to google chrome extension.
I came across crossrider siderbar plugin. But, I am unable to change the url for sidebar dynamically.
Do we have any other crossrider plugins which opens like an popup ?
Answer Q1: You can use our appAPI.tabs.onTabSelectionChanged(function callback([{tabId, tabUrl}])) method (soon to be documented). To keep track of the ActiveTab URL, in the callback, simply set a global variable to the callback's optional tabUrl parameter. This is currently supported in Chrome and Firefox.
Answer Q2: I'm afraid that currently there isn't a native popup plugin (your welcome to write one and submit it for consideration ;-)). However, you can configure and use jQueryUI popups from within the extension.
I need to get active tab url in IE.
If it is not possible using jquery in IE, can we use messaging api to send messages from pages to background scope, and store the active tab url in background's global variable?
some time ago I read an article that it is possible to use the url adress bar in an google chrome extension.
E.g. wikipedia stackoverflow will search for stackoverflow and open the wikipedia site.
However I can't find any reference about that feature: http://code.google.com/chrome/extensions/getstarted.html
Can you provide some information on that?
I found it! It's called Omnibox
The omnibox API allows you to register
a keyword with Google Chrome's address
bar, which is also known as the
omnibox.
from https://developer.chrome.com/extensions/omnibox
Type a site name, press tab, then finish typing your search. It's a pretty strange UI concept but that's how it works. For example if you've visited stackoverflow.com before then go to the address bar and type "stackoverflow.com" then hit the tab key, the address bar changes to say "Search Stack Overflow:". You can press tab as soon as it suggests the domain name to switch to this search mode.
No extension needed.