This repository contains the necessary code to generate a bookmarklet and a webpage where users can drag and drop the bookmarklet to their browsers.
The final webpage is hosted using GitHub Pages. To help with the deployment to the gh-pages branch, we are mixing code from the bookmarklet and the web within the same repository.
Contains the bookmarklet code. main.js
checks the current webpage against the supported sites and requests and runs the appropriate script to make the download possible.
Contains the html and assets of the webpage. The contents of this folder will be copied and merged with the final bookmarklet scripts on build. Web files don't receive any special treatment from the builder (no transformation, no minification, etc.). This could be improved, but right now the webpage is not the main priority of this repository and I don't want to end with yet another react webpage. 💃
npm install
Generate the final bookmarklet scripts and merge them with the content from src-web
npm run build
Generate and serve the bookmarklet code.
npm run dev
Run all available tests.
npm test
Tests are divided into two folders.
We can run just the tests from this folder with:
npm run test:unit
These tests will run the bookmarklet final code. The tests make use of puppeteer to open a page in a browser and insert the bookmark script.
To make the bookmarklet final script available to puppeteer, a temporary server (utils/tests_server.js
) will be started. The server will shut down after the tests are done.
In order to serve the correct files, a build
needs to be done before running the integration tests (our ci GitHub workflows always run build
before test
).
Currently, these tests make real connections to the supported pages. Because of that, test results could be flaky (page down, timeout, etc.), but it will give us the best representation of an user running the bookmarklet.
We can run just the tests from this folder with:
npm run test:integration