Scramjet

Scramjet is an interception-based web proxy designed to evade internet censorship, bypass arbitrary web browser restrictions and innovate web proxy technologies. It strives to maintain security, developer friendliness and performance unlike many other web proxies regardless of its open source nature.
Scramjet is currently the flagship web proxy made by Mercury Workshop and it is highly recommended that you switch to it. Don’t worry, it is stable enough for most use cases to go into production!
How to setup Scramjet on your proxy site
Section titled “How to setup Scramjet on your proxy site”-
Install the package:
pnpm install https://github.com/MercuryWorkshop/scramjet/releases/download/latest/mercuryworkshop-scramjet-1.0.2-dev.tgz
(PNPM is recommended unless you use an alternative runtime like Bun) -
Serve the Scramjet build under your specified route using the path
import { scramjetPath } from "@mercuryworkshop/scramjet/path"
. We will use/scram/
as a route for these examples. -
Write a SW
sw.js
:
importScripts("/scram/scramjet.all.js");
const { ScramjetServiceWorker } = $scramjetLoadWorker();
const scramjet = new ScramjetServiceWorker();
self.addEventListener("fetch", (event) => {
event.respondWith(async () => {
await scramjet.loadConfig();
if (scramjet.route(event)) {
return scramjet.fetch(event);
}
return fetch(event.request);
});
});
- Initialize
BareMux
andScramjetController
, and register your SW.
Import the scripts in this order:
- BareMux
- BareMux Transport of your chioce
- Scramjet all bundle
In your JS Script:
const { ScramjetController } = $scramjetLoadController();
const scramjet = new ScramjetController({
files: {
wasm: "/scram/scramjet.wasm.wasm",
all: "/scram/scramjet.all.js",
sync: "/scram/scramjet.sync.js",
}
});
scramjet.init();
navigator.serviceWorker.register("sw.js");
// Init BareMux
const connection = new BareMux.BareMuxConnection("/baremux/worker.js");
// Set the transport yourself
connection.setTransport(...);
Note about upgrading to a new CI build
Section titled “Note about upgrading to a new CI build”Until Scramjet has an NPM package, you have to use the CI builds, which run every time a commit is pushed to main
.
If you want to upgrade to a new CI build and you use PNPM, you must type pnpm cache delete @mercuryworkshop/scramjet
and then install it again.
Upgrading
Section titled “Upgrading”To 1.0.2-dev+
Section titled “To 1.0.2-dev+”Now, Scramjet uses a new main bundle scramjet.all.js
, which combines the former scripts.
Replaces these bundles:
<link rel="prefetch" href="/scram/scramjet.worker.js" />
<link rel="prefetch" href="/scram/scramjet.shared.js" />
...
<script src="/scram/scramjet.controller.js"></script>
From Ultraviolet
Section titled “From Ultraviolet”Scramjet is easier to setup than UV. You may still use UV alongside Scramjet if you really find it necessary, however UV is unmaintained software and has far less site support than Scramjet.
With:
<script src="/scram/scramjet.all.js"></script>
Learn from examples
Section titled “Learn from examples”Here is an example setup of Scramjet as a proxy site. If you get lost and need a reference along the way, you can fork it or take inspiration from it. It’s essentially Ultraviolet-App, but with Scramjet as the SW proxy instead.
Official docs
Section titled “Official docs”You can read the full Scramjet Typedocs for better API documentation.