Chrome extension to issue Ecosia search queries after Google ones were submitted.
Core Idea • Architecture • Additional Features • Platform Support • Browser Support • Installation • Run Manually
The idea of utilizing ad revenue to plant trees is undoubtedly a revolutionary concept since climate change has become a serious problem. Unfortunately, this upside of Ecosia is pretty quickly getting outweighed in the real world by its less effective search algorithms as compared to Google. This encourages a substantial amount of people potentially belonging to its userbase to eventually returning to Google not making the permanent switch.
But what if it was possible to get the best of both worlds?
This project aims on providing the search results of a conventional Google search to the user while generating ad revenue for Ecosia in the best case or at least supporting its attractiveness to advertisers in the worst case. For achieving this goal, ecosia-postloader intercepts Google search queries using a browser extension, builds the equivalent Ecosia search query and eventually issues it via a Selenium Chrome WebDriver in the background. This ensures that the ad-networks can not distinguish the request from a real one and serve their ads as a consequence.
Due to the Selenium driver being very resource heavy, a simple http request with a real user-agent is issued instead if the operating device of the user is not currently charging. If proceeded differently, the user could experience his battery discharging rapidly, but on the flipside, when not using the Selenium approach it is questionable whether Ecosia would load ads.
Prior to sending requests from the Selenium WebDriver, the host process has to be up and running. After init.py was run (see Installation) this should take place automatically when the trigger process is launched.
If the user issues a Google search request with the browser extension enabled and the host server running:
- Extension registers the query and builds the ecosia equivalent
- Extension emits Ecosia query to the host via a WebSocket channel
- Extension issues GET request to Ecosia URL using the fetch API
- Host initiates Selenium to build headless Chrome instance
- WebDriver issues GET request to Ecosia URL using the Chrome instance
- WebDriver clicks on predefined number of ads on served page and stays on them for fixed amount of time
- WebDriver terminates, host responds to extension with clicked links
- Battery Mode: If operating device is not charging, Selenium WebDriver is disabled
- Rate Limit Detection: If being rate limited, disable all requests for 24 hours. Selenium WebDriver Requests permanently restricted to 1 concurrent connection and minimum time of 1s between requests
- Clicked Ads Log: Extension provides log about all ads clicked during the last search request
While the browser extension is platform independent, the automatic startup of the WebSocket server on trigger process launch is not.
Platform | |
---|---|
MacOS | ✔️ Supported |
Windows | ➖ In Testing |
Linux | ❌ Not scheduled |
Any browser based on the Chromium project, such as Google Chrome, Brave or Edge.
Only tested version numbers are listed.
Note, that for at least MacOS the terminal has to be privileged to manipulate the file system.
- Clone the repository
- Open shell/terminal/cmd and navigate to the directory
- Run
python3 init.py
- Run
npm install
insideextension/
- Open the chromium-based browser of your choice and navigate to the extensions page (usually found under
{browser}://extensions
) - Enable the developer mode and click on
load unpacked extension
- Upload the extension stored in
extension/
from project root
After having followed the instructions above, the host application should start autonomously as soon as the specified trigger was launched.
For development purposes however, it is also possible to directly run npm start
inside host/
in order to start the WebSocket server.
Note that the extension might has to be reloaded as well when frequently stopping and starting the server.
The project and the corresponding source code serve solely for the interest and illustration of the technical possibilities. I assume no liability for any detrimental usage of the source code. The mere presence/publication of this code on my Github account does not imply that I encourage scraping or scrape ecosia.org or any other website.