Last active
December 23, 2020 17:54
-
-
Save markomitranic/c663ad7a4c493fc7d90e55e63b3a6abd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simply paste all of this code on any instagram post. | |
// Or drag the file to the console and press Enter. | |
function init() { | |
loadAllComments(); | |
} | |
function loadAllComments() { | |
// Load all comments pages... | |
const clickerInterval = setInterval(() => { | |
overlay.innerText = 'Still Working...'; | |
const nextButton = document.querySelector('.glyphsSpriteCircle_add__outline__24__grey_9'); | |
if (nextButton) { | |
nextButton.click(); | |
} else { | |
overlay.innerText = 'Finished loading pages. Clearing interval.'; | |
window.clearInterval(clickerInterval); | |
expandReplies(); | |
} | |
}, 1500); | |
} | |
function expandReplies() { | |
// Load all replies to comments... | |
const buttons = document.querySelectorAll('.EizgU'); | |
let currentIndex = buttons.length - 1; | |
const clickerInterval = setInterval(() => { | |
if (currentIndex >= 0) { | |
overlay.innerText = 'Clicking a replies link: ' + currentIndex; | |
buttons[currentIndex].click(); | |
currentIndex--; | |
} else { | |
overlay.innerText = 'Finished loading replies. Clearing interval'; | |
window.clearInterval(clickerInterval); | |
clearBody(); | |
} | |
}, 1500); | |
} | |
function clearBody() { | |
var commentsHtml = document.querySelector('.XQXOT').innerHTML; | |
document.body.innerHTML = ` | |
<style type="text/css"> | |
#list { | |
display: none; | |
} | |
#display { | |
width: 100%; | |
height: 100vh; | |
position: relative; | |
} | |
#display ul { | |
list-style-type: none; | |
padding: 0; | |
margin: 0; | |
} | |
#display ul li { | |
display: none; | |
position: absolute; | |
width: 100%; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50%, -50%); | |
text-align: center; | |
font-size: 40px; | |
font-family: Helvetica; | |
padding: 0; | |
margin: 0; | |
} | |
#display ul li.active { | |
display: block; | |
} | |
</style> | |
<div id="count">Total count is: <span></span></div> | |
<div id="display"> | |
<ul> | |
</ul> | |
</div> | |
<ul id="list"> | |
<!-- STUFF PASTE ZONE --> | |
</ul>`; | |
document.querySelector('#list').innerHTML = commentsHtml; | |
document.body.append(overlay); | |
setTimeout(() => { | |
overlay.innerText = 'Waiting for spin'; | |
parseData(); | |
}, 2000); | |
} | |
function parseData() { | |
setTimeout(() => { | |
var originalList = document.querySelectorAll('#list h3 a'); | |
var list = document.querySelector('#display ul'); | |
const elementsList = []; | |
for(var i = 0; i < originalList.length; i++) { | |
var li = document.createElement('li'); | |
li.innerText = originalList[i].innerText; | |
list.append(li); | |
elementsList.push(li); | |
} | |
var counter = document.querySelector('#count span'); | |
counter.innerText = elementsList.length; | |
timeout(0); | |
document.body.addEventListener('click', () => { timeout(0); }); | |
overlay.innerText = "Click anywhere to spin again."; | |
function timeout(previousTimeout) { | |
var newTimeout = previousTimeout + 5; | |
if (newTimeout >= 220) { | |
return; | |
} | |
setTimeout(function() { | |
var index = getRandom(); | |
elementsList[index].classList.add('active'); | |
removeSiblings(index); | |
timeout(newTimeout); | |
}, newTimeout); | |
} | |
function removeSiblings(index) { | |
for(var m = 0; m < elementsList.length; m++) { | |
if (m !== index) { | |
elementsList[m].classList.remove('active'); | |
} | |
} | |
} | |
function getRandom() { | |
return Math.floor(Math.random() * elementsList.length); | |
} | |
}, 3000); | |
} | |
function createOverlay() { | |
let overlay = document.querySelector('#overlay'); | |
if (!overlay) { | |
overlay = document.createElement('div'); | |
overlay.style = "width: auto;max-width: 150px; display: block; background-color: rgb(235, 235, 235); position: fixed;border: 1px solid rgb(218, 218, 218);color: gray;text-align: center; bottom: 0px; right: 0px; line-height: 12px; font-size: 10px; z-index: 9999999999; border-top-left-radius: 6px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; padding: 2px 6px;" | |
overlay.innerText = 'Loading...'; | |
document.body.append(overlay); | |
} | |
return overlay; | |
} | |
overlay = createOverlay(); | |
init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment