I'm developing a Chrome Extension which blocks the ads & get the Ad Video ID. But I'm facing a problem that to do all of that I've to right click on video for menu & click on "stats for nerds". By doing so the HTML Elements for Ad Video ID & Video ID appear on the source code which then I can use for all my work.
The main problem is how to automatically right click for the menu. As I'm building a chrome extension the code needs to be in JavaScript I think, if there is an other way please let me know.
I've tried to use selenium to right click but selenium initiates it's own browser not what we're working on. And I also don't know if selenium works in Chrome extension.
My code:- (Before skipping we are getting stats for nerds html class & clicking on it. In JS, I'm able to click but not right click. )
function handleSkipBtn() {
if (skipBtn.length > 0) {
//This Lines of code is used to get ad video ID. I just want to open stats of nerds here 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();
}
}
I jus need a way to right click automatically in JavaScript file for chrome extension.