Skip to content

Instantly share code, notes, and snippets.

@hltbra
Created May 15, 2012 23:29
Show Gist options
  • Save hltbra/2705971 to your computer and use it in GitHub Desktop.
Save hltbra/2705971 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Udacity EXT - Auto next video&quiz
// @description Udacity Extension -- Automatically go to the next video or quiz question upon reaching the end of the current one
// @namespace http://sepczuk.com/
// @version 0.2
// @include http://www.udacity.com/view*
// @match http://www.udacity.com/view*
// @copyright 2012, Damian Sepczuk, Hugo Lopes Tavares
// ==/UserScript==
function mainWrapper(){
function main(){
if (window.App.player === undefined) {
setTimeout(main, 300);
return;
}
App.player.addEventListener('onStateChange', function(p){
if (p.data === YT.PlayerState.ENDED) {
$('#course-next-button .button').click();
}
})
};
main();
};
if (!document.xmlVersion) {
var script = document.createElement('script');
script.appendChild(document.createTextNode('('+ mainWrapper +')();'));
document.documentElement.appendChild(script);
}
@bernardobarreto
Copy link

1- I notice that you create mainWrapper being self callable, why don't you do the same with the main function?:

function main(){
...
}();

2- if you jquery to make the click, why can't you use in the rest of the code ?

3- when you make the click you're selecting an element with a specific id and class, can't you select just by the id (theoretically the page must have just one element with that id)

my changes:
https://gist.github.com/2707337

@bernardobarreto
Copy link

I got ride of the mainWrapper function, but you did this function because of the timeout right?

@hltbra
Copy link
Author

hltbra commented May 16, 2012

This gist is based on this script: http://userscripts.org/scripts/review/126694, and I only adapted it.

I just "fixed" it to work with the new Udacity UI, made no refactoring/improvement :-)

@bernardobarreto
Copy link

ok then.. =P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment