From 593914f0870478d71e889603cb83c26cf5f23432 Mon Sep 17 00:00:00 2001 From: Arend-Jan Tetteroo Date: Tue, 30 Jun 2020 15:22:49 +0200 Subject: [PATCH] Create architecture.md Readd comments on architecture by Chris --- docs/architecture.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 docs/architecture.md diff --git a/docs/architecture.md b/docs/architecture.md new file mode 100644 index 0000000..b106466 --- /dev/null +++ b/docs/architecture.md @@ -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