gothfox/Tiny-Tiny-RSS-Notifier-for-Chrome — pull request #1 by dandersson (2013-04-09 11:59:32+00:00)
Title: Refactor code to avoid extension deprecation by Google.

See for more info on extension deprecation.

Summarized: Google will incrementally remove support for `manifest_version` <2. Already new versions of Chrome won't load them in developer mode, they won't be accepted in the store and since March 2013 updates to existing extensions with this old version are not allowed in the web store. In July they will stop showing in the web store and in September they won't load at all. The TT-RSS extension has no version specified, which accounts to version 1.

Beyond just setting the new version number, there are quite a lot of other changes in extension handling. Changes needed in this specific case:

* `manifest_version` is set to 2 in `manifest.json`.
* The `background_page` directive is no longer allowed in favor of the `background` directive with different arguments. There is no need for a dummy `background.html` page that loads the JS anymore, since `background` takes a script parameter directly (and internally generates a minimal `background.html` equivalent, but that's a technicality).
* Explicit permissions is given to the new `alarms` API. More info on that below.
* The inline JS declarations in `background.html` were moved to `js/background.js`, with these additional changes (all at the very bottom of the file):
* the `init();` function is run explicitly since we don't have `

` available any longer.
* `setTimout()` is no longer allowed, and thus replaced by the new [`alarm` API](http://developer.chrome.com/extensions/alarms.html). Currently this alarm will trigger once every minute, when `timeout()` checks if it is time to update item count/feed with the same logic as before. This could be simplified in the future.
* the onClicked logic was slightly simplified without change in function.
* The inline JS declarations in `options.html` were moved to `js/options.js`, with these additional changes (all at the very bottom of the file):
* the earlier `

` trigger in `options.html` which is no longer allowed is replaced by the `document.addEventListener('DOMContentLoaded' ...)` construct. Here we register the `onsubmit` action on the submit button and the `single_user_toggle` action on the "Single user mode" checkbox and run `init()`, to get the old behavior.

Also, the JS was cleaned up code-style wise with [`gjslint` from Closure tools](https://developers.google.com/closure/utilities/) according to [Google's JS style guidelines](http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml) since it was all in flight anyway (in practice concerns indentation and max line length).

This makes the plugin function again in developer mode and should make it eligible for the web store. I have more changes lined up to make the plugin more current and add some small functionality, but I'll hold off those pull requests until this big one that keeps all functionality intact (I believe) has settled.