Created
March 6, 2023 19:50
-
-
Save aoirint/5f71d7cb6e2645185a945df122043525 to your computer and use it in GitHub Desktop.
This file contains 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
asinList = []; | |
videoList = []; | |
setInterval(() => { | |
const cards = document.querySelectorAll('[data-testid="card"]') | |
for (let card of cards) { | |
const url = card.querySelector('[href^="/gp/video/detail/"').href; | |
const urlMatch = url.match(/\/gp\/video\/detail\/(.+)\/.+$/); | |
if (!urlMatch) continue; | |
const videoAsin = urlMatch[1]; | |
const videoTitle = card.dataset.cardTitle; | |
const sourceWebpTag = card.querySelector('source[type="image/webp"]'); | |
const sourceJpegTag = card.querySelector('source[type="image/jpeg"]'); | |
const sourcePngTag = card.querySelector('source[type="image/png"]'); | |
let thumbnailSrcset = null; | |
if (sourceWebpTag != null) { | |
thumbnailSrcset = sourceWebpTag.srcset; | |
} else if (sourceJpegTag != null) { | |
thumbnailSrcset = sourceJpegTag.srcset; | |
} else if (sourcePngTag != null) { | |
thumbnailSrcset = sourcePngTag.srcset; | |
} else { | |
continue; // not loaded yet | |
} | |
const cardUnentitledParentTag = card.querySelector('._8w2yV3'); | |
const unentitledTag = cardUnentitledParentTag != null ? cardUnentitledParentTag.querySelector('[data-testid="unentitled-icon"]') : null; | |
const unentitled = unentitledTag != null; | |
const unentitledText = cardUnentitledParentTag != null ? cardUnentitledParentTag.innerText : null; | |
if (!asinList.includes(videoAsin)) { | |
asinList.push(videoAsin); | |
videoList.push({ | |
'asin': videoAsin, | |
'title': videoTitle, | |
'thumbnailSrcset': thumbnailSrcset, | |
'unentitled': unentitled, | |
'unentitledText': unentitledText, | |
}); | |
} | |
} | |
}, 100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment