https://github.com/userjhansen/get-js-var-deno
Fetch a Javascript variable from html or js string
https://github.com/userjhansen/get-js-var-deno
deno deno-module denoland
Last synced: 4 months ago
JSON representation
Fetch a Javascript variable from html or js string
- Host: GitHub
- URL: https://github.com/userjhansen/get-js-var-deno
- Owner: UserJHansen
- Created: 2021-07-11T23:46:01.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-07-12T03:47:17.000Z (almost 4 years ago)
- Last Synced: 2025-02-18T15:02:40.928Z (4 months ago)
- Topics: deno, deno-module, denoland
- Language: TypeScript
- Homepage:
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Get JS variable Deno 🦕
Fetch a Javascript variable from html or js string **without** evaling the page
# Setup
```ts
import { FindVariable } from "https://deno.land/x/get_js_var/mod.ts";//
// Code for Example.org withadded script tag that set the TargetVar variable
//
const target = "TargetVar";const html =
"\n\n\n Example Domain\n\n \n \n \n \n body {\n background-color: #f0f0f2;\n margin: 0;\n padding: 0;\n font-family: -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;\n \n }\n div {\n width: 600px;\n margin: 5em auto;\n padding: 2em;\n background-color: #fdfdff;\n border-radius: 0.5em;\n box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);\n }\n a:link, a:visited {\n color: #38488f;\n text-decoration: none;\n }\n @media (max-width: 700px) {\n div {\n margin: 0 auto;\n width: auto;\n }\n }\n \n \n var TargetVar = 1\n \n\n\n\n\n\n\n\n";Example Domain
\nThis domain is for use in illustrative examples in documents. You may use this\n domain in literature without prior coordination or asking for permission.
\n \nconst result = FindVariable(target, html);
console.log(result);
```