Uses Tampermonkey to load and run script(s), possibly written in TypeScript, from remote source(s) on a webage.
Example use case: A script that adds a custom control panel (from your own code bundle) on a page you visit often, manipulating the web page with jQuery (loaded from a CDN).
Tampermonkey has built-in functionality for handling script versions and updates, but the alternative approach implemented in this project has some other interesting features:
- Host your actual sript(s) code (apart from the loader) wherever, outside of Tampermonkey.
- No need to interact with Tampermonkey for versions or updates.
- Load multiple remote scripts from different sources.
Based on rollup-starter-app.
- Create a new script in the Tampermonkey dashboard.
- If you do this at the page where you want to run the script, the initial value for
@matchis set such that the script will run at that page.
- If you do this at the page where you want to run the script, the initial value for
- Update the information in tampermonkey.config.js
bundleUrlshould point to where you host your bundled script.- Set the value for
@matchso that the script will run at the proper sites.
- Modify src/index.ts and other source files, in either JavaScript or TypeScript, to implement the features you need.
- Build the project (see Development).
- In the Tampermonkey dashboard, replace the content of your newly created script with the contents of public/tampermonkey.js.
- In your browser, navigate to the page where you want the script to run and Tampermonkey will load your specified scripts on the page.
Clone this repository and install dependencies
git clone https://github.com/mast4461/tampermonkey-remote-script-loader
cd tampermonkey-remote-script-loader
yarnyarn run build builds the tampermonkey script public/tampermonkey.js and the bundle script public/bundle.js, along with a sourcemap file for debugging public/bundle.js.map.
yarn start launches a server, using serve. Navigate to localhost:3000.
yarn run watch will continually rebuild the application as your source files change.
yarn run dev will run yarn start and yarn run watch in parallel.