Skip to content

Instantly share code, notes, and snippets.

@MihailPreis
Created June 28, 2021 19:24
Show Gist options
  • Save MihailPreis/df1e1acad5efa092a3b42725086ceab4 to your computer and use it in GitHub Desktop.
Save MihailPreis/df1e1acad5efa092a3b42725086ceab4 to your computer and use it in GitHub Desktop.
Ghost random Telegram post
<div id="tg-post"></div>
<script>
let GROUP_NAME = ""
let MIN_POST_ID = 3
let MAX_POST_ID = 100
function randomIntFromInterval(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min)
}
let post_id = randomIntFromInterval(MIN_POST_ID, MAX_POST_ID);
var script = document.createElement('script');
script.src = "https://telegram.org/js/telegram-widget.js?15";
script.async = true;
script.setAttribute('data-telegram-post', GROUP_NAME + "/" + post_id)
script.setAttribute('data-width', "100%")
script.setAttribute('data-color', "343638")
script.setAttribute('data-dark-color', "FFFFFF")
document.getElementById('tg-post').appendChild(script);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment