Introduction

This chrome extension displays a minimalist clock as well as the weather.

Working on making the extension taught me a lot regarding what goes into making one for chrome. From how to store the user's preferences, to background scripts and content scripts that get injected into web pages, this was a great learning experience. For future proof reasons, I decided to use the version 3 of the manifest file.

For the weather, I used the openWeather API to fetch the weather data. The API is free but the number of calls is limited to 60 per minute. As such i utilized the chrome alarm API to fetch the weather data every hour, as to limit the number of calls. Once fetched, the response is parsed and the data is stored in chrome's local storage. A listener on the content script is set up to listen to the storage change event and update the weather accordingly.
The user's position is updated in the popup as it is impossible to get it in the background script.

The time displayed on each of the clocks is simply updated using the js setInterval function. The clocks are updated every minute as they do not display the seconds.

Format changes are handled in the popup. The user can change the time and temperature format. This change is stored in chrome's local storage, and once again, the content script (ie: the clock element in each page) is listening to the storage change event and updates the clock accordingly.

Try out the extension

To try the app out just head over to the chrome web store and download the extension (using chrome is a requirement).

Beautiful frosted glass effect

The clock element displays both the time and the local temperature in a very pleasing frosted glass effect.

Keep track of time even in fullscreen

The clock element can be displayed in fullscreen mode, allowing you to keep track of the time at all moments.

Popup

The extension popup gives you more options:

  • Update position: update the position used for the weather update
  • 24H/12H: switches between the 24 hour format and 12 hour format
  • °C/°F: switches between degree celcius and degree fahrenheit
  • Hide/Show: hides or show the clock element

Commands

  • Hide: Ctrl+Shift+Up or Command+Shift+Up
  • Show: Ctrl+Shift+Down or Command+Shift+Down