|
1 | 1 | {% comment %} |
2 | | -<!-- |
3 | | -Code used for embedding Gumroad on the Hydejack Site. |
4 | | -Left here for reference, feel free to delete. |
5 | | ---> |
6 | | -<link rel="dns-prefetch" href="https://assets.gumroad.com"> |
7 | | -<script type="module"> |
8 | | - let p; |
9 | | - const promisify = f => x => new Promise(r => f(x).addEventListener('load', r)); |
10 | | - const loadJS = promisify(window.loadJS); |
11 | | - document.querySelector('hy-push-state').addEventListener('load', () => { |
12 | | - const io = new IntersectionObserver(async (entries) => { |
13 | | - if (entries.some(x => x.isIntersecting)) { |
14 | | - p = p || loadJS('https://gumroad.com/js/gumroad-embed.js'); |
15 | | - await p; |
16 | | - if (!window.GumroadEmbed) { |
17 | | - await new Promise(function check1(res) { |
18 | | - if ('createGumroadEmbed' in window) res(window.createGumroadEmbed()); |
19 | | - else setTimeout(() => check1(res), 200); |
20 | | - }); |
21 | | - } |
22 | | - await new Promise(function check2(res) { |
23 | | - if ('GumroadEmbed' in window) res(GumroadEmbed.reload()); |
24 | | - else setTimeout(() => check2(res), 200); |
25 | | - }); |
26 | | - } |
27 | | - }, { rootMargin: '1440px' }); |
28 | | - document.querySelectorAll('.gumroad-product-embed').forEach(el => io.observe(el)); |
29 | | - }); |
30 | | -</script> |
31 | | -<script type="module"> |
32 | | - let p; |
33 | | - const promisify = f => x => new Promise(r => f(x).addEventListener('load', r)); |
34 | | - const loadJS = promisify(window.loadJS); |
35 | | - document.querySelector('hy-push-state').addEventListener('load', () => { |
36 | | - const io = new IntersectionObserver(async (entries) => { |
37 | | - if (entries.some(x => x.isIntersecting)) { |
38 | | - p = p || loadJS('https://gumroad.com/js/gumroad.js'); |
39 | | - await p; |
40 | | - if (!window.GumroadOverlay) { |
41 | | - await new Promise(function check(res) { |
42 | | - if ('createGumroadOverlay' in window) res(window.createGumroadOverlay()); |
43 | | - else setTimeout(() => check(res), 200); |
44 | | - }); |
45 | | - } |
46 | | - } |
47 | | - }, { rootMargin: '300px' }); |
48 | | - document.querySelectorAll('.gumroad-button').forEach(el => io.observe(el)); |
49 | | - }); |
50 | | -</script> |
| 2 | + |
51 | 3 | {% endcomment %} |
0 commit comments