Skip to content

Instantly share code, notes, and snippets.

@dwisiswant0
Created August 8, 2023 10:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwisiswant0/838e7432820e55137b306e64c6a441fc to your computer and use it in GitHub Desktop.
Save dwisiswant0/838e7432820e55137b306e64c6a441fc to your computer and use it in GitHub Desktop.
Auto view & like Instagram stories (minified + bookmarklet)
javascript:void(async function(){window.utils={isValidURL:e=>"www.instagram.com"!==e.host?(alert("Buka www.instagram.com lah, pekok."),!1):!!e.pathname.startsWith("/stories/")||(alert("Jangan diinterrupt, blok."),!1),emulateClick:e=>{const t=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0});e.dispatchEvent(t)},emulateNext:()=>{const e=new KeyboardEvent("keydown",{key:"ArrowRight",keyCode:39,code:"ArrowRight",which:39,bubbles:!0,cancelable:!0});document.dispatchEvent(e)},getKuki:e=>{const t=document.cookie.split(";");for(const i of t){const[t,o]=i.trim().split("=");if(t===e)return decodeURIComponent(o)}return null},sleep:e=>new Promise((t=>setTimeout(t,e))),fatalError:e=>{console.error("Failed to like the story.",e),alert("Waduh! Refresh gan."),window.location.replace("/")}},window.aing={token:utils.getKuki("csrftoken"),kirimLike:async (t)=>{const i=await fetch("/api/v1/story_interactions/send_story_like",{method:"POST",mode:"cors",credentials:"include",headers:{"content-type":"application/x-www-form-urlencoded","viewport-width":"852","x-csrftoken":aing.token,"x-ig-app-id":"936619743392459","x-requested-with":"XMLHttpRequest"},body:`media_id=${t}`});if(i.ok)try{const e=await i.json();"ok"!==e.status?console.error("Failed to like the story.",e,window.location.href):console.log("Ok, ngab!",window.location.href),utils.emulateNext(),await utils.sleep(500),aing.hajar()}catch(e){utils.fatalError(e)}else 400==i.status?utils.emulateNext():utils.fatalError(e)},hajar:()=>{const e=new URL(window.location.href);if(!utils.isValidURL(e))return;const t=e.pathname.split("/")[3];aing.kirimLike(t)},init:async ()=>{const e=document.querySelector('button[tabindex="0"]');utils.emulateClick(e),await utils.sleep(3e3),aing.hajar()}};await aing.init()})()
@dwisiswant0
Copy link
Author

How?

Press [Ctrl][Shift][B] to bring down your Google Chrome bookmark bar. Right-click within the bookmark bar area, followed by selecting the Add page option. In the bookmark edit dialog, fill out the page Name with anything you want (e.g., "Auto View & Like IG Stories"), then Paste this script into URL field.
Now, you are set! So, whenever you visit a https://www.instagram.com, just click on the bookmarklet.

Note: If you familiar with https://aingcreations2014.blogspot.com/2013/06/bookmarklets-collection.html, ykwim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment