Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script language="JavaScript">
- var wrapper, content, test;
- var more = ''
- var imgIndex = 0;
- function getRandomAttachment() {
- min = Math.ceil(999999);
- max = Math.floor(100000);
- res = Math.floor(Math.random() * (max - min) + min);
- return `<img src="https://forums.somethingawful.com/attachment.php?attachmentid=${res}"></img>`
- }
- function scroller() {
- console.log('scroll height: ', window.scrollY)
- console.log('imgIndex: ', imgIndex)
- console.log('last image height: ', document.body.children[0].children[imgIndex].y)
- if (
- (window.innerHeight + window.scrollY) >= document.body.children[0].children[imgIndex].y - 2
- ) {
- console.log('hit bottom')
- content.innerHTML += getRandomAttachment();
- imgIndex += 1;
- }
- }
- </script>
- </head>
- <body>
- <div id="content" style="height: 100vh;"></div>
- <script language="JavaScript">
- content = document.getElementById("content");
- content.innerHTML = getRandomAttachment();
- if (window.addEventListener)
- window.addEventListener("scroll", scroller, false);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement