Skip to content

Instantly share code, notes, and snippets.

@replete
Created March 2, 2024 14:44
Show Gist options
  • Save replete/73bc07db249dec7d2cb18adb01b35107 to your computer and use it in GitHub Desktop.
Save replete/73bc07db249dec7d2cb18adb01b35107 to your computer and use it in GitHub Desktop.
Save all URLs from Instagram saved page on desktop
if (!window.ripperLinks) window.ripperLinks = [];
window.ripperCount = 0;
window.ripperFunc = function(){
document.querySelectorAll('article [role=link]').forEach(el => {
ripperLinks.push(el.href);
});
let uniqueLinks = ripperLinks.filter(function(elem, index, self) {
return index === self.indexOf(elem);
});
ripperLinks = uniqueLinks;
ripperurls.innerText = uniqueLinks.join('\n');
let blob = new Blob([ripperurls.innerText], {type: 'octet/stream'});
let url = window.URL.createObjectURL(blob);
rippersave.href = url;
window.scrollBy(0, window.innerHeight * 2);
ripperCount += 1;
if (ripperCount >= 20) {
window.clearInterval(ripperInterval);
ripperbutton.disabled = false;
alert('URL rip complete');
}
console.log(`links ripped after ${ripperCount} scrolls:`, ripperLinks.length);
}
window.startRipper = function() {
window.ripperInterval = window.setInterval(ripperFunc,7000);
ripperbutton.disabled = true;
}
let ripperButton = document.createElement('button');
ripperButton.onclick = ripperFunc;
ripperButton.style = 'position:fixed; top:0; right:0';
ripperButton.innerText = 'Rip URLs';
ripperButton.id = 'ripperbutton';
document.body.appendChild(ripperButton);
let ripperUrls = document.createElement('pre');
ripperUrls.style = 'position:fixed; top: 20px; right:0; width: 300px; height:300px; display:block; background: white; border:1px solid grey; overflow: scroll;';
ripperUrls.id = 'ripperurls';
document.body.appendChild(ripperUrls);
let ripperSave = document.createElement('a');
ripperSave.style = 'position:fixed; top:330px; right:0; background: #ccc; padding:3px; border-radius:2px;';
ripperSave.innerText = 'Save to .txt';
ripperSave.download = 'instagramURLs.txt';
ripperSave.id = 'rippersave';
ripperSave.href = '#';
document.body.appendChild(ripperSave);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment