-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
37 lines (33 loc) · 1.24 KB
/
background.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
var fa = document.createElement('style');
fa.type = 'text/css';
fa.textContent = '@font-face { font-family: FontAwesome; src: url("'
+ chrome.extension.getURL('font-awesome-4.4.0/fonts/fontawesome-webfont.woff?v=4.4.0')
+ '"); }';
document.head.appendChild(fa);
try {
$(".ytp-chrome-controls").append('<input type="checkbox" value="loop" name="YTlooper" style="display:none"><i name="YTRepeatFacade" class="fa fa-refresh YTElement" title="Put on loop"></i>')
if($(".ytp-chrome-controls") === null) throw "No YT Element presen0t";
}
catch(err) {
console.log(err);
}
$("i[name='YTRepeatFacade']").click(function(){
$("input[name='YTlooper']").trigger("click")
})
$("input[name='YTlooper']").change(function(){
looper($(this));
})
function looper(checkBoxElement){
vidElement = $("video");
if($(checkBoxElement).is(":checked") === false)
{
vidElement.prop("loop", false);
$("i[name='YTRepeatFacade']").removeClass("YTActive");
$("i[name='YTRepeatFacade']").attr("title", "Put on loop");
return
}
vidElement.get(0).play();
vidElement.prop("loop", true)
$("i[name='YTRepeatFacade']").addClass("YTActive");
$("i[name='YTRepeatFacade']").attr("title", "Remove loop");
}