https://github.com/abcnews/hash-scripts-loader
https://github.com/abcnews/hash-scripts-loader
library
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/abcnews/hash-scripts-loader
- Owner: abcnews
- License: mit
- Created: 2020-07-01T00:58:40.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2025-12-02T05:45:16.000Z (7 months ago)
- Last Synced: 2025-12-04T20:46:35.440Z (7 months ago)
- Topics: library
- Language: TypeScript
- Homepage:
- Size: 3.61 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hash-scripts-loader
Load scripts with a #hash in Core.
## Install
Install module
```sh
npm install @abcnews/hash-scripts-loader
```
Put in code
```javascript
import loadScripts from "@abcnews/hash-scripts-loader";
loadScripts();
```
## Usage
Put something like `#interactivescriptsENCODEDldhgjldkjg3lk43nlkjbnsdlkfn` in a CoreMedia article. With the encoded string being a [base-36-props](https://github.com/abcnews/base-36-props) string. Use the [base 36 converter](https://www.abc.net.au/res/sites/news-projects/base-36-props-converter/1.0.0/) to get the string.
Use the following pattern.
```json
{"scripts": ["https://path.to.your.com/script.js"]}
```
Multiple scripts supported. eg.
```json
{
"scripts": [
"https://path.to.your.com/script.js",
"https://path.to.another.com/script.js"
]
}
```
## Proxy
When using the preview site you can proxy a local script using `proxy` and `proxyencoded` query strings.
- `?proxy=https://ws204914.aus.aunty.abc.net.au:8000/index.js` seems to work only on `https://master-news-web.news-web-preview.presentation-layer.abc-prod.net.au` domain NOT nucwed
- `?proxyencoded=5flhz4us1jwv2ryyloaj9zytj0scx2zv3at3b2mgy8p2gnwf1xw1araikd8atfti1h6hfse65289hftsamn2oco3e5tcin6trz542ef1` with the encoded string something like the following (works in nucwed preview):
```
{ "scripts": ["https://ws246352.aus.aunty.abc.net.au:8000/index.js"] }
```
Use this [base36 encoding tool](https://www.abc.net.au/res/sites/news-projects/base-36-props-converter/1.0.0/) to get the string.
## Standalone loader
Attach this standalone JavaScript file to your CoreMedia article to use [this loader](https://github.com/phocks/interactive-loader) in Presentation Layer.
To do this, create a new JavaScript document and paste the URL into the URL field and check it in. Then attach the JS document in your article.
`https://www.abc.net.au/res/sites/news-projects/interactive-loader/1.1.2/index.js`
*Note: Currently only works if Odyssey PL JS is also attached to the article*