MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / method3

Function method3

scripts/insta_injectDownloadBtn.js:582–601  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

580
581 // method 3
582 async function method3() {
583 let postId = await findPostId(articleNode);
584 if (!postId) {
585 return null;
586 }
587
588 if (!(postId in mediaIdCache)) {
589 let postUrl = `https://www.instagram.com/p/${postId}/`;
590 let resp = await fetch(postUrl);
591 let text = await resp.text();
592 let idMatch = text ? text.match(mediaIdPattern) : [];
593 let mediaId = null;
594 for (let i = 0; i < idMatch.length; ++i) {
595 if (idMatch[i]) mediaId = idMatch[i];
596 }
597 if (!mediaId) return null;
598 mediaIdCache[postId] = mediaId;
599 }
600 return mediaIdCache[postId];
601 }
602
603 function method2() {
604 let scriptJson = document.querySelectorAll(

Callers 1

findMediaIdFunction · 0.85

Calls 1

findPostIdFunction · 0.85

Tested by

no test coverage detected