From b933604f444329f674cf766fd3b272611d336b9f Mon Sep 17 00:00:00 2001 From: j4k0xb <55899582+j4k0xb@users.noreply.github.com> Date: Mon, 17 Jun 2024 01:43:41 +0200 Subject: [PATCH] feat: add url query param from old repo --- apps/docs/src/guide/web.md | 10 ++++------ apps/playground/src/App.tsx | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/apps/docs/src/guide/web.md b/apps/docs/src/guide/web.md index 85c94ee3..b439d0e0 100644 --- a/apps/docs/src/guide/web.md +++ b/apps/docs/src/guide/web.md @@ -18,15 +18,13 @@ It runs entirely in the browser, so the code never leaves your computer. Pass either `code` or `url` parameters to load code into the editor. Keep in mind to encode them (e.g. `encodeURIComponent` in js). -| Parameter | Description | -| --------- | -------------------------------------------- | -| `code` | Code as a string (max length: ~16,000) | -| `url` | URL to fetch code from | -| `run` | Automatically start deobfuscation (optional) | +| Parameter | Description | +| --------- | -------------------------------------- | +| `code` | Code as a string (max length: ~16,000) | +| `url` | URL to fetch code from | Examples: -- [/?code=1-1&run](https://webcrack.netlify.app/?code=1-1&run) - [/?url=https://pastebin.com/raw/ye3usFvH](https://webcrack.netlify.app/?url=https%3A%2F%2Fpastebin.com%2Fraw%2Fye3usFvH) ::: info diff --git a/apps/playground/src/App.tsx b/apps/playground/src/App.tsx index 8e493882..85e6ff85 100644 --- a/apps/playground/src/App.tsx +++ b/apps/playground/src/App.tsx @@ -181,6 +181,25 @@ function App() { ]); } + (async () => { + const queryParams = new URLSearchParams(location.search); + const urlParam = queryParams.get('url'); + const codeParam = queryParams.get('code'); + + if (urlParam !== null) { + const response = await fetch(urlParam).catch(() => + fetch('https://corsproxy.io/?' + encodeURIComponent(urlParam)), + ); + if (response.ok) { + const model = activeTab() || openUntitledTab(); + model.setValue(await response.text()); + } + } else if (codeParam !== null) { + const model = activeTab() || openUntitledTab(); + model.setValue(codeParam); + } + })().catch(console.error); + return (