Skip to content

Commit

Permalink
Added Telegram iframe v3
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Jun 25, 2024
1 parent 0c6ac52 commit 029a13a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
38 changes: 38 additions & 0 deletions iframe/3/telegram.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<title>Content from Telegram</title>
<body style="margin:0">
<script>
((hash, window) =>
{
const isDark = /theme=dark/.test(hash) || (/theme=auto/.test(hash) && window.matchMedia('(prefers-color-scheme:dark)').matches);

window.onload = () =>
{
document.body.innerHTML = '<iframe loading="eager" scrolling="no" src="//t.me/' + hash.replace(/#.*|[^\w\/]/g, '') + '?embed=1' + (isDark ? '&dark=1' : '') + '" style="border:0;height:100vh;width:100%"></iframe>';
};

let height, port;
window.onmessage = (e) =>
{
let m = /"height":(\d+)/.exec(e.data);
if (m)
{
height = +m[1];
}
else if (e.data === 's9e:init:3')
{
port = e.ports[0];
}
else
{
// Ignore messages that we don't recognize
return;
}

if (height && port)
{
port.postMessage({ 'method': 'resize', 'height': height });
}
};
})(location.hash.substring(1), window);
</script>
1 change: 1 addition & 0 deletions iframe/3/telegram.min.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><title>Content from Telegram</title><body style=margin:0><script>((a,b)=>{const g=/theme=dark/.test(a)||/theme=auto/.test(a)&&b.matchMedia('(prefers-color-scheme:dark)').matches;b.onload=()=>{document.body.innerHTML='<iframe loading=eager scrolling=no src=//t.me/'+a.replace(/#.*|[^\w\/]/g,'')+'?embed=1'+(g?'&dark=1':'')+' style=border:0;height:100vh;width:100%></iframe>'};let c,d;b.onmessage=e=>{let f=/"height":(\d+)/.exec(e.data);if(f)c=+f[1];else if('s9e:init:3'===e.data)d=e.ports[0];else return;c&&d&&d.postMessage({method:'resize',height:c})}})(location.hash.substring(1),window)</script>

0 comments on commit 029a13a

Please sign in to comment.