Created
June 6, 2023 18:21
-
-
Save kongmunist/a598bcdd8c226c3a3159b1a918344977 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
// From the blog post andykong.org/blog/icloudconfusion/ | |
function boxTops(){ | |
HTMLCollection.prototype.toArray = function() { return Array.from(this); } | |
// Select all the time badges and parse out their total runtime in seconds | |
a = document.getElementsByClassName('video-text-badge').toArray() | |
b = a.map((x) => x.innerText) | |
c = b.map((y) => y.split(":").map((x) => parseInt(x))) | |
d = c.map((x) => x[0]*60 + x[1]) | |
// Sort the badges HTML array and badges runtime together | |
indices = Array.from(a.keys()) | |
indices.sort( (x,y) => d[x] - d[y]) | |
sortedA = indices.map(i => a[i]) | |
sortedD = indices.map(i => d[i]) | |
// Function that boxes an element | |
function drawBox(element) { | |
if (element instanceof HTMLElement) { | |
element.style.border = "2px solid red"; | |
} | |
} | |
thresh = 30 // Min seconds to highlight a video | |
for (let i = 0; i < sortedD.length; i++) { | |
if (sortedD[i] > thresh){ | |
drawBox(sortedA[i]) | |
} | |
} | |
} | |
// Continuously highlight big videos | |
setInterval(boxTops, 500) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment