The initial motivation for creating this extension was to replace the dead 'Dream After' extension that I had been using for many years.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
If you are new to Browser extension development, I highly recommend reading the official documentation first.
https://developer.chrome.com/extensions
This is the reference for the available API from Chrome.
https://developer.chrome.com/extensions/api_index
-
Download the Source Code: Clone the repository to your local machine.
-
Set Up Environment Variables: Create a
.envfile in the root directory of the project. Fill in the API keys by registering for the free developer programs onPEXELSandOpen Weather. You can refer to the.env.local.examplefile for the structure.Example
.envfile:PEXELS_API_KEY=your_pexels_api_key OPENWEATHERMAP_API_KEY=your_openweathermap_api_key -
Configure API Endpoints: The API keys will be automatically picked up from the
.envfile. Ensure that yourwallpaper.jsandweather.jsfiles are set up to use these environment variables.-
PEXELS images:
PEXELS: { url: 'https://api.pexels.com/v1/search?', name: 'pexels', key: process.env.PEXELS_API_KEY }
-
Open Weather API:
class Weather { constructor() { this.BASE = { api: "https://api.openweathermap.org/data/2.5/onecall", key: process.env.OPENWEATHERMAP_API_KEY, }; } }
-
-
Install Dependencies: Run the following command to install the necessary dependencies:
npm install
To start developing the extension, follow these steps:
-
Run the Development Server: Use Webpack's development server to serve the extension locally.
npm run start:chrome:dev npm run start:edge:dev -
Load the Unpacked Extension:
- Open the Extension Management page by navigating to
chrome://extensions. - Enable Developer Mode by clicking the toggle switch next to Developer mode.
- Click the LOAD UNPACKED button and select the ./dist directory.
- Open the Extension Management page by navigating to
-
Hot Module Replacement: The development server supports hot module replacement, allowing you to see changes in real-time without reloading the extension.
To prepare the extension for production, follow these steps:
-
Build the Extension: Run the Webpack build scripts to create optimized production builds.
npm run build:chrome:prod npm run build:edge:prod -
Package the Extension: Zip the
distfolder and upload it to the related Web Store.
Any ideas or development contributions are welcome.