how to add google extensions
Hi, my name is Roshan.I'm a developer advocate on the Google Chrome team. And I'm attending to show you ways to create Google Chrome Extensions. We'll begin out with a summary of the extension building. Then, we'll practice some code associated places along an example step by step. But before we have a tendency to get to the technical stuff, let's observe what extensions ar. Google Chrome Extensions are largely little programs that add bits of practicality to google Chrome.
They install instantly while not a browser restart. And, like Google Chrome, they update wordlessly once new versions are obtainable. We designed the extension system with net developers in mind. If you'll be able to produce web content, you recognize just about all you wish to grasp to form GoogleChrome extensions. In fact, extensions are enforced with nothing however normal net technologies -- markup language, CSS, JavaScript, and so on. An extension could be a compressed directory -- a signed nada, to be precise -- with a bunch of net files in it.
The one file each extension must have a manifest file. it is also the one file that must have a selected name, that is "manifest.json". because the name implies, the manifest file is JSON-formatted information -- specifically, information that describes the extension lists permissions and points to the extension's alternative elements. Those elements are what offer the extension of its practicality. the associate extension includes one or additional of the subsequent elements. Browser actions and page actions are the twoUI surfaces the extension system ships with ab ignition.
A browser action seems within the toolbar of each tab. A page action by selection seems within the Omnibox and may be toggled on or off for every tab. An extension will solely have one UI surface or the opposite. We'd wish to encourage extension developers to be as stripped-down in their style selections because the Google Chrome team is. Content scripts are impulsive CSS and JavaScriptthat ar injected into elect pages. they are kind of like user scripts and may be used as a UI various to browser and page actions. Background pages are long-running scripts that assist you to manage state and coordinate tasks across extension elements. As associate extension gets additionally complicated, it tends to want a background page. additionally to those elements that are specific to Google Chrome Extensions, you'll be able to bundle the other net files together with your extension -- pictures, JavaScript libraries, Flash movies, no matter it's your extension desires.
The extension API is little and simple to be told. It presently defines concerning forty objects and40 ways. "chrome" is that the name of the top-ranking object mechanically exposed to any or all extensions. The API is split into six modules, that are described by objects contained within the "chrome" object." chrome.extension" has properties and ways that allow you to send messages to speak between extension elements and resolve the URLs of extension files." chrome. browser action" helps you to set the looks of browser actions and their badges, that ar mini text areas overlaid on browser actions. "chrome. pagination" helps you to change and disable page actions. "chrome. windows" helps you to open, close, lookup, and update browser windows. It needs "tabs" permission in your manifest file. that is not a typographical error -- windows and tabs are thus closely connected they share typical permission. "chrome. tabs" helps you to perform constant actions on tabs.
It conjointly needs "tabs" permission. And "chrome. bookmarks" helps you to browse from and write to the user's marker tree and needs "bookmarks" permission. Now, let's do this stuff out by iteratively developing an associate extension. Our extension is going to be a Google Chrome Twitter client, that we'll decision Critter. First, we'll offer the extension a basic, “HelloWorld”-type UI. Of course, we want a manifest file. In it, we have a tendency to specify the extension's name, version variety, description, and icon. For the UI half, we're attending to choose a browser action as a result of, well, we wish our tweets handy {at all|in the least|the least bit|in the slightest degree|in associated respect} times! we have a tendency to populate the browser-action fields with an icon that may seem within the toolbar, a tooltip that may seem once the user mouse over the icon, and a
popup bubble which will seem once the user clicks on the icon. For now, the popup could be a trivial hypertext mark-up language file. when putting in our extension, we tend to get -- as publicized -- associate icon, a tooltip, and a popup. The popup asks: "Wouldn't it's nice to visualize some tweets here?"And I feel it might be nice, therefore let's add, therefore! We'll do so by attractive Twitter's public timeline with XMLHttpRequest.Back in our manifest file, we tend to fire permission to form cross-origin requests to twitter.com so we are able to access Twitter's API. we tend to fire "tabs" permission, as well, therefore we are able to open UI links in new tabs. And in our popup file, we tend to strengthen the HTMLby inserting a title and a guide to gift the attributes of every tweet -- a link to the user's profile, their image, and name, and also the tweet itself.
We even have new JavaScript for retrieving and displaying the timeline. When the load event fires, we tend to run associate "init" perform to grab references to the various guide parts via XPath. That perform hands management over to a different performance to try to to the XHR work. "getTweets" problems a straightforward request for JSON feed, and successively, hands management over to the request perform "process tweets".The process performs deserializes the incoming JSON mistreatment V8's built-in JSON support associated stores the lead to an array.
Iterating through the array of tweets, the"update" perform assigns every guide attribute and appends the illegible tweet to the popup. Our extension encompasses a heap a lot of occurring currently, with a sophisticated UI and also the most up-to-date public tweets to indicate off. Our implementation is not ideal, though. As a final step, let's improve the extension's performance and practicality by refactoring your code. Namely, we should always flip our popup into a dumb view therefore it solely is aware of a way to update its show and offload the remainder of the work to a background page. We'll act and add a background page to our manifest.
Then, we are able to strip the XHR code out of our popup. in situ of that code, we tend to give a contribution a relevance to the background page, that is coming by the "getBackgroundPage" technique. The popup does not collect tweets any longer, therefore we tend to use the background relevance tell through the obtainable tweets instead. we tend to move the XHR code to its new digs within the background page, however not while not a few upgrades. I mentioned we tend to might improve performance and practicality and here's wherever we'll. Since the background page is not tied to any DOM event, the page will fetch tweets on a continuous loop.
That way, we are able to batch tweets up and have them prepared before the user even invokes the popup.We specify a frequency for attractive -- ten seconds for demo functions -- and manage {the process|the technique} with the "setInterval" method. whereas we're at it, we are able to conjointly titivate them. we tend to currently have a variable variety of batched tweets, which could be an excellent candidate for the show with a browser-action badge.We vogue the badge with "setBadgeBackgroundColor" and pass within the variety of uninformed tweets with"setBadgeText". Our extension does not look a full heap totally different direction. however, if we tend to let it assume for touch, we tend to see a badge that dynamically updates the tweet count.
tags:- my chrome extensions
chrome extensions settings
chrome extensions android
google themes
remove chrome extensions
download extension
chrome website
add store
The popup ought to work identically, though we tend to probably have a great deal a lot of tweets to scroll through currently. While this version of brute makes for a pleasant toy, there square measure some options we'd wish to feature for it to be really helpful. On the highest of that list would be incorporating the user's friend timeline -- instead of the general public timeline -- which might need baking OAuth into the extension. Things will get a touch bushy there. Luckily, we've already done the work for you associated have an example of a brute with OAuth support. we tend to even have an additional example that handles custom motor vehicle change. To transfer that code, the code you simply saw, and more, go to code.google.com/chrome/extensions. Thanks for the look and rejoice building google Chrome Extensions!
No comments:
Post a Comment