Skip to content

Instantly share code, notes, and snippets.

@dijux
Created July 5, 2022 22:07
Show Gist options
  • Save dijux/411a2cdb343a7c8df7824a1344eaeecc to your computer and use it in GitHub Desktop.
Save dijux/411a2cdb343a7c8df7824a1344eaeecc to your computer and use it in GitHub Desktop.
var redParts = document.querySelectorAll(".ytp-play-progress.ytp-swatch-background-color");
var fullCurrentWidth = (redParts.length) * 2*(-1);
var fullWidth = (redParts.length - 1) * 2*(-1);
redParts.forEach((e, index) => {
var width = Number(e.parentElement.parentElement.style.width.replace("px", ""));
var scale = parseFloat(e.style.transform.replace("scaleX(", "").replace(")", ""));
var currentWidth = width * scale;
fullCurrentWidth += (index == redParts.length -1 && scale != 0) ? parseFloat(currentWidth) + 1*2*(-1) : parseFloat(currentWidth);
fullWidth += parseFloat(width);
});
var fobj1 = {
// currentPercentage: getYtMarkerPosition(obj.currentTimestamp, obj.fullLength),
currentPercentage: redParts.length == 1 ?
parseInt(redParts[playerIndex].style.transform.replace("scaleX(", "").replace(")", ""))
: fullCurrentWidth/fullWidth,
};
document.querySelectorAll(".ytp-play-progress.ytp-swatch-background-color")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment