Skip to content

Commit

Permalink
feat: add url query param from old repo
Browse files Browse the repository at this point in the history
  • Loading branch information
j4k0xb committed Jun 16, 2024
1 parent e5a28b6 commit b933604
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
10 changes: 4 additions & 6 deletions apps/docs/src/guide/web.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions apps/playground/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<DeobfuscateContextProvider
code={activeTab()?.getValue()}
Expand Down

0 comments on commit b933604

Please sign in to comment.