I am developing a Chrome extension for Youtube and when the user clicks a button that I have created I want to simulate a mouse hover over the player, without moving the mouse. When a video is playing and the mouse is, manually, hovered over the player, the controls (play, pause etc) and the progress bar shows and this is what I am trying to accomplish, but with a button click instead of hovering.
I don't want to pause the video, only show the bottom controls and progress bar when the user clicks the button I have created.
manifest.json
//name, description, background etc
"content_scripts": [
{
"matches": ["http://www.youtube.com/*", "https://www.youtube.com/*"],
"js": ["jquery.js", "content.js"]
}
]
content.js
$('#myButton').on('click', function() {
//I have tried the following:
$('#movie_player').trigger('mouseenter')
$('#movie_player').mouseenter()
document.getElementById('movie_player').onmouseenter()
//I can play/pause the video with:
$('#movie_player').click()
}
I have also tried "mouseover" (jQuery) and "onmouseover" (javascript) and I have also tried these on several different child elements of the #movie_player without success.
When hovering manually over the player, Chrome's DevTools shows me that the #movie_player element has a class (ytp-autohide) which gets removed/added when the mouse is entering/leaving the element. However. I can't just remove this class when the user clicks my button because then the progress bar/duration time is not updated.
Any ideas?