Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getTimeInSeconds(text) {
- let p = 0, sum = 0;
- while (text.length > 0) {
- sum += Math.pow(60, p) * text.substring(text.length - 2);
- text = text.substring(0, text.length - 3);
- p++;
- }
- return sum;
- }
- function convertTime(seconds) {
- let hours = ~~(seconds/3600);
- seconds = seconds - (hours*3600);
- let minutes = ~~(seconds/60);
- seconds = seconds - (minutes*60);
- console.log(`${hours}:${minutes}:${seconds}`);
- }
- let sum = 0;
- document.querySelectorAll("span.style-scope.ytd-thumbnail-overlay-time-status-renderer").forEach(el => {
- let text = el.innerText;
- sum += getTimeInSeconds(text);
- });
- convertTime(sum);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement