Skip to content

Instantly share code, notes, and snippets.

@aniket91
Last active November 11, 2017 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aniket91/7d1da89190beb1446a3c7bcf53b181b7 to your computer and use it in GitHub Desktop.
Save aniket91/7d1da89190beb1446a3c7bcf53b181b7 to your computer and use it in GitHub Desktop.
Greasemonkey script to automatically replay finshed songs in youtube
// ==UserScript==
// @name YoutubeReplayScript
// @include http://*.youtube.com/*
// @include https://*.youtube.com/*
// @require http://code.jquery.com/jquery-1.7.1.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @description Replays songs automatically once it is finished playing.
// @namespace http://opensourceforgeeks.blogspot.in/
// @version 1
// @grant none
// ==/UserScript==
(function(){
function actionFunction(node){
console.log ("Found replay button. Clicking it!");
//node.click();
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('click', true, true);
node[0].dispatchEvent (clickEvent);
return true;
}
console.log ("Waiting for replay button");
waitForKeyElements("[title|='Replay']", actionFunction);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment