-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmy-head.html
51 lines (51 loc) · 1.96 KB
/
my-head.html
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
{% comment %}
<!--
Code used for embedding Gumroad on the Hydejack Site.
Left here for reference, feel free to delete.
-->
<link rel="dns-prefetch" href="https://assets.gumroad.com">
<script type="module">
let p;
const promisify = f => x => new Promise(r => f(x).addEventListener('load', r));
const loadJS = promisify(window.loadJS);
document.querySelector('hy-push-state').addEventListener('load', () => {
const io = new IntersectionObserver(async (entries) => {
if (entries.some(x => x.isIntersecting)) {
p = p || loadJS('https://gumroad.com/js/gumroad-embed.js');
await p;
if (!window.GumroadEmbed) {
await new Promise(function check1(res) {
if ('createGumroadEmbed' in window) res(window.createGumroadEmbed());
else setTimeout(() => check1(res), 200);
});
}
await new Promise(function check2(res) {
if ('GumroadEmbed' in window) res(GumroadEmbed.reload());
else setTimeout(() => check2(res), 200);
});
}
}, { rootMargin: '1440px' });
document.querySelectorAll('.gumroad-product-embed').forEach(el => io.observe(el));
});
</script>
<script type="module">
let p;
const promisify = f => x => new Promise(r => f(x).addEventListener('load', r));
const loadJS = promisify(window.loadJS);
document.querySelector('hy-push-state').addEventListener('load', () => {
const io = new IntersectionObserver(async (entries) => {
if (entries.some(x => x.isIntersecting)) {
p = p || loadJS('https://gumroad.com/js/gumroad.js');
await p;
if (!window.GumroadOverlay) {
await new Promise(function check(res) {
if ('createGumroadOverlay' in window) res(window.createGumroadOverlay());
else setTimeout(() => check(res), 200);
});
}
}
}, { rootMargin: '300px' });
document.querySelectorAll('.gumroad-button').forEach(el => io.observe(el));
});
</script>
{% endcomment %}