Skip to content

Instantly share code, notes, and snippets.

@nthung2112
Created March 8, 2017 03:15
Show Gist options
  • Save nthung2112/9f43ff5eefbffd1176509ab148cb878b to your computer and use it in GitHub Desktop.
Save nthung2112/9f43ff5eefbffd1176509ab148cb878b to your computer and use it in GitHub Desktop.
window.addEventListener("load", function(event) {
var videoElm = $("#movie_player").find('video')[0];
addButtonReplay(videoElm);
$(videoElm).on('play', function(e) {
addButtonReplay(videoElm);
});
});
function addButtonReplay(videoElm) {
var buttonReplay = $('<button type="button" style="background-color: #4285F4;color: white;height:24px;padding: 0 5px;border-radius:4px;cursor:pointer;outline:none;">Replay</button>');
$("#watch7-subscription-container .yt-uix-button-subscription-container").prepend(buttonReplay);
buttonReplay.click(function() {
if ($(videoElm).attr('loop')) {
$(videoElm).removeAttr('loop');
$(buttonReplay).css({ 'background-color': '#4285F4' });
} else {
$(videoElm).attr('loop', true);
$(buttonReplay).css({ 'background-color': '#0b51c5' });
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment