I am currently working on a program that has the ability to block YouTube ads and keep track of the blocked Ad Video IDs.
To achieve this, our selenium program needs to simulate a right click on the video to open the video menu and then select "stats for nerds". This action will reveal the HTML Elements for the Ad Video ID and Video ID in the source code, which we can utilize.
One major obstacle I am encountering is figuring out how to automatically trigger a right click for the video menu. While Selenium can handle left clicks to pause the video, it does not have a built-in functionality for right clicks.
Here is a snippet of my current code:
function handleSkipBtn() {
if (skipBtn.length > 0) {
//The following code extracts the ad video ID. I would like to access stats for nerds and then close it.
var a = document.getElementsByClassName("ytp-sfn-cpn");
if (a.length > 0) {
var b = a[0].innerText;
alert(b);
}
skipBtn[0].click();
}
}