Skip to content

Commit

Permalink
Create architecture.md
Browse files Browse the repository at this point in the history
Readd comments on architecture by Chris
  • Loading branch information
arendjantetteroo authored Jun 30, 2020
1 parent b571a4b commit 593914f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Key parts

# Updating the browser chrome on the page

The web extension works by relying on on the background.js to make calls to the API, in response to listeners being triggered when a page loads, or tab is activated.

In both cases `doGreencheckForTabReplace` is called, calling `getGreencheck` which then calls `doRequest` to update the chrome for the given tab, with the grey/green icon.

# Updating the page DOM - links to green sites, and annotating search results

In addition to updating the browser chrome, the extension also adds extra markup on the page on browsers, using the content scripts, `search-all.js`, `search-bing.js` and so on.

These send messages to background.js with `runtime.sendMessage`, which triggers `chrome.runtime.onMessage` in background.js. This calls `doSearchRequest`, which triggers a batched API request with `doApiRequest`, to send info back to the tab, to update the DOM.

More info on:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webNavigation/onCommitted
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts#Communicating_with_background_scripts
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/sendMessage

0 comments on commit 593914f

Please sign in to comment.