-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathext.js
47 lines (41 loc) · 1.42 KB
/
ext.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// ==UserScript==
// @name Coursera - auto play next video
// @description Coursera Extension to automatically go to the next video when the video is over (prevents annoying purchase certificate banners)
// @version 1.0
// @namespace https://www.github.com/sh0oki/coursera-autoplay
// @source https://www.github.com/sh0oki/coursera-autoplay
// @include https://*.coursera.org/learn/*/lecture/*/*
// @match https://*.coursera.org/learn/*/lecture/*/*
// @require https://code.jquery.com/jquery-2.2.3.min.js
// @copyright 2016, sh0oki
// ==/UserScript==
function mainWrapper() {
var debug = false;
var US_SHORT_NAME = 'CEXT';
var US_VERSION = 1.0;
function debugLog(msg) {
if (!debug) return;
console.log(US_SHORT_NAME + ": " + msg);
}
function main() {
v = $('video');
if (v.length === 0) {
setTimeout(main, 300);
return;
}
v[0].addEventListener("ended", function(){
debugLog("Video ended");
if (configuredAutoNext()) {
$('div.right-actions a').last()[0].click()
}
});
}
function configuredAutoNext() {
b = $('.c-autoplay-button-container button.selected')[0];
return b.classList.contains("c-autoplay-on-button");
}
main();
};
$(document).ready(function() {
mainWrapper()
});