blob: c944cdd1bd3f0a0955147aea9867f17b8fdf44e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
import {createRoot} from 'react-dom/client'
import {Widget} from './Widget'
import {App} from "@/models/app.ts"
import {Provider} from 'react-redux'
import {store} from './store'
import {setApp} from "@/models/appSlice.ts";
import "@/index.css"
(function () {
// Finding the script tag on the page..
const scriptTags = document.querySelectorAll('script[data-bpuid]');
let currentScript: HTMLScriptElement | null = null;
for (const tag of scriptTags) {
currentScript = tag as HTMLScriptElement;
}
// GRL Snippet configuration options
const settings: App = {
targetId: currentScript?.getAttribute("data-target") || 'grl-widget',
bpid: currentScript?.getAttribute("data-bpid") || "invalid-bpid-from-snippet",
bpuid: currentScript?.getAttribute("data-bpuid") || "invalid-bpuid-from-snippet",
offerwall: currentScript?.getAttribute("data-offerwall") || "37d1da64",
walletMode: Boolean(currentScript?.getAttribute("data-wallet")) || true,
panelName: currentScript?.getAttribute("data-panel") || null,
leaderboard: Boolean(currentScript?.getAttribute("data-leaderboard")) || false,
currentPage: "offerwall"
} as App
store.dispatch(setApp(settings))
// Avoid adding the widget multiple times
const container: HTMLElement | null = document.getElementById(settings.targetId)
if (container) {
// ensure that it's empty?
} else {
let container = document.createElement('div')
container.id = settings.targetId
document.body.appendChild(container)
}
const root = createRoot(container)
root.render(
// <React.StrictMode>
<Provider store={store}>
<Widget/>
</Provider>
// </React.StrictMode>
);
})()
|