Skip to content

Commit

Permalink
Updated Threads iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Jul 12, 2023
1 parent 1c80e31 commit f11e152
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 16 additions & 7 deletions iframe/2/threads.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,31 @@
if (e.data === 's9e:init' && !port)
{
port = e.ports[0];
updateParent();
}
else if (/^\d+$/.test(e.data))
{
height = +e.data;

// NOTE: Threads always messages that the iframe should be 186 px tall first so
// we delay it for a little bit to leave it time to get the correct height
if (height === 186)
{
setTimeout(updateParent, 3000);
}
else
{
updateParent();
}
}
else
{
// Ignore messages that we don't recognize
return;
}
};

// NOTE: Threads always messages that the iframe should be 186 px tall first
function updateParent()
{
if (height && port)
{
port.postMessage(height);
}
};
}
})(document, window);
</script>
2 changes: 1 addition & 1 deletion iframe/2/threads.min.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><title>Content from Threads</title><body style=margin:0><script>((c,e)=>{e.onload=()=>{const a="//www.threads.net/t/"+location.hash.replace(/\W/g,"");c.body.innerHTML="<iframe allowfullscreen loading=eager scrolling=no style=background:#fff;border:0;border-radius:12px;height:100vh;width:100% src="+a+"/embed/></iframe><a target=_blank style=display:block;line-height:100vh;position:absolute;text-align:center;top:0;width:100% href="+a+">Loading Threads...</a>";c.querySelector("iframe").onload=()=>{const f=c.querySelector("a");f&&f.remove()}};let d,b;e.onmessage=a=>{if("s9e:init"!==a.data||b)if(/^\d+$/.test(a.data))d=+a.data;else return;else b=a.ports[0];d&&b&&b.postMessage(d)}})(document,window)</script>
<!DOCTYPE html><title>Content from Threads</title><body style=margin:0><script>((d,f)=>{function e(){b&&c&&c.postMessage(b)}f.onload=()=>{const a="//www.threads.net/t/"+location.hash.replace(/\W/g,"");d.body.innerHTML="<iframe allowfullscreen loading=eager scrolling=no style=background:#fff;border:0;border-radius:12px;height:100vh;width:100% src="+a+"/embed/></iframe><a target=_blank style=display:block;line-height:100vh;position:absolute;text-align:center;top:0;width:100% href="+a+">Loading Threads...</a>";d.querySelector("iframe").onload=()=>{const g=d.querySelector("a");g&&g.remove()}};let b,c;f.onmessage=a=>{"s9e:init"!==a.data||c?/^\d+$/.test(a.data)&&(b=+a.data,186===b?setTimeout(e,3E3):e()):(c=a.ports[0],e())}})(document,window)</script>

0 comments on commit f11e152

Please sign in to comment.