This project houses a web extension for Nspect. Nspect is a system designed to provide consumers with better supply chain information so that they can make more informed purchasing decisions. To run the extension:
git clone git@github.com:jtsec92/webextension.git
npm install
npm install --save @angular/material @angular/cdk @angular/animations
ng add @angular/material
npm run start
NOTE: changes to the content page and service worker scripts requires you to reload the extension in chrome://extensions
./angular/src/manifest.json
npm run build:production
extension-build.zip
to the chrome webstorechrome://extensions/
webextension/angular/dist
and make sure the dist
folder is highlightedWhen making changes just use hotkey CTRL-R
on the chrome://extensions/
page to
reload the page. Chrome will reload the extension.
The current testing framework utilizes the Java Robot Framework due to the project's need for automated testing that supports native OS inputs (keyboard press and mouse clicks).
to Build, Execution, Deployment | Build Tools | Maven | Repositories
and select Repositories
on the left and click Update
.tests/src
and click Run 'All tests'
to add a run configuration to IntelliJ that will run all of the tests.Note: On Mac, go to System Preferences->Security & Privacy->Privacy->Accessibility
and then make sure the check mark next to IntelliJ
or the IDE of your choice is checked so that Java has the correct permissions otherwise the Robot class will not run.
If on Mac, Linux, or Git Bash copy the ChromeDriver
binary to /usr/local/bin
and run the command xattr -d com.apple.quarantine chromedriver
in the /usr/local/bin
directory to
give the chromedriver
binary the correct permissions. Test this by running chromedriver
in the terminal.
To generate a private key with OpenSSL on Linux/Mac follow these SO steps:
# 1. Create private key called key.pem
2>/dev/null openssl genrsa 2048 | openssl pkcs8 -topk8 -nocrypt -out key.pem
# 2. Generate string to be used as "key" in manifest.json (outputs to stdout)
2>/dev/null openssl rsa -in key.pem -pubout -outform DER | openssl base64 -A
# 3. Calculate extension ID (outputs to stdout)
2>/dev/null openssl rsa -in key.pem -pubout -outform DER | shasum -a 256 | head -c32 | tr 0-9a-f a-p
and set the key
value in manifest.json
to the value obtained from step 2. The value from step 3 is the extension ID used for testing.
These links are useful for understanding the code base. The core architecture of a Chrome Extension is made up of a contentScript.js page, a popover, and a service worker script. The code base here makes use of Angular which relies on Typescript thus knowledge of Typescript is required. jQuery mixed into Typescript is the current tool of choice to extract elements from the DOM.
TBD