Skip to content

Commit

Permalink
Updated TikTok iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Jul 13, 2023
1 parent efd6c73 commit c1a56e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions iframe/2/tiktok.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<title>Content from TikTok</title>
<body style="margin:0">
<script>
((body, window) =>
((document, window) =>
{
window.onload = () =>
{
// TikTok has a solid white background that bleeds outside of the rounded content inside
body.innerHTML = '<iframe allowfullscreen="" loading="eager" scrolling="no" style="border:0;border-radius:8px;height:calc(100vh - 1px);margin:0;width:100%" src="//www.tiktok.com/embed/v2/' + location.hash.replace(/\D/g, '') + '"></iframe>';
document.body.innerHTML = '<iframe allowfullscreen="" loading="eager" scrolling="no" style="border:0;border-radius:8px;height:calc(100vh - 10px);margin:0;width:100%" src="//www.tiktok.com/embed/v2/' + location.hash.replace(/\D/g, '') + '"></iframe>';
};

let height, port;
Expand All @@ -19,9 +19,9 @@
port = e.ports[0];
e.stopImmediatePropagation();
}
else if ((m = /height":(\d+)/.exec(e.data)) && height !== m[1])
else if (m = /height":(\d+)/.exec(e.data))
{
height = m[1];
height = +m[1];
}
else if (/ready/.test(e.data))
{
Expand All @@ -35,10 +35,10 @@
return;
}

if (height && port)
if (height && port && height !== window.innerHeight)
{
port.postMessage(height);
}
};
})(document.body, window);
})(document, window);
</script>
2 changes: 1 addition & 1 deletion iframe/2/tiktok.min.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><title>Content from TikTok</title><body style=margin:0><script>((f,e)=>{e.onload=()=>{f.innerHTML='<iframe allowfullscreen loading=eager scrolling=no style="border:0;border-radius:8px;height:calc(100vh - 1px);margin:0;width:100%" src=//www.tiktok.com/embed/v2/'+location.hash.replace(/\D/g,"")+"></iframe>"};let b,c;e.onmessage=a=>{let d;if("s9e:init"===a.data)c=a.ports[0],a.stopImmediatePropagation();else if((d=/height":(\d+)/.exec(a.data))&&b!==d[1])b=d[1];else if(/ready/.test(a.data))document.querySelector("iframe").style.height="100vh";else return;b&&c&&c.postMessage(b)}})(document.body,window)</script>
<!DOCTYPE html><title>Content from TikTok</title><body style=margin:0><script>((e,c)=>{c.onload=()=>{e.body.innerHTML='<iframe allowfullscreen loading=eager scrolling=no style="border:0;border-radius:8px;height:calc(100vh - 10px);margin:0;width:100%" src=//www.tiktok.com/embed/v2/'+location.hash.replace(/\D/g,"")+"></iframe>"};let b,d;c.onmessage=a=>{let f;if("s9e:init"===a.data)d=a.ports[0],a.stopImmediatePropagation();else if(f=/height":(\d+)/.exec(a.data))b=+f[1];else if(/ready/.test(a.data))e.querySelector("iframe").style.height="100vh";else return;b&&d&&b!==c.innerHeight&&d.postMessage(b)}})(document,window)</script>

0 comments on commit c1a56e3

Please sign in to comment.