Skip to content

Commit 9013ea2

Browse files
committed
Fixed a bug when looping a playlist video and then clicking next
Loop stays on until explicitly changed
1 parent 87de5bb commit 9013ea2

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

.eslintrc.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@ rules:
1919
- error
2020
- multi-or-nest
2121
- consistent
22+
23+
brace-style:
24+
- error
25+
- stroustrup
26+
- allowSingleLine: true

js/content_script.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,22 @@ function addObserver() {
6262
const video = document.querySelector('video');
6363
const observer = new MutationObserver((mutations) => {
6464
mutations.forEach((mutation) => {
65-
if (mutation.attributeName === 'src' ||
66-
(mutation.attributeName === 'loop' && video.getAttribute('loop') === null && rotated === true)) {
67-
rotated = false;
68-
updateToggleControls(COLOR_OFF, TITLE_OFF, DEGREE_OFF);
69-
document.querySelector('[role=menuitemcheckbox]').setAttribute('aria-checked', rotated);
70-
} else if (mutation.attributeName === 'loop' && video.getAttribute('loop') !== null && rotated === false) {
71-
rotated = true;
72-
updateToggleControls(COLOR_ON, TITLE_ON, DEGREE_ON);
73-
document.querySelector('[role=menuitemcheckbox]').setAttribute('aria-checked', rotated);
65+
if (mutation.attributeName === 'loop') {
66+
if (video.getAttribute('loop') === null && rotated) {
67+
rotated = false;
68+
updateToggleControls(COLOR_OFF, TITLE_OFF, DEGREE_OFF);
69+
}
70+
else if (video.getAttribute('loop') !== null && !rotated) {
71+
rotated = true;
72+
updateToggleControls(COLOR_ON, TITLE_ON, DEGREE_ON);
73+
}
7474
}
7575
});
7676
});
7777
observer.observe(video, { attributes: true });
7878
}
7979

80+
// Add control over the YouTube context menu
8081
function addContextMenuListener() {
8182
const video = document.querySelector('video');
8283
video.addEventListener('contextmenu', () => {

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 2,
33
"author": "Marko Kajzer",
44
"name": "YouLoop",
5-
"version": "0.4.1",
5+
"version": "0.5.0",
66
"description": "Put YouTube videos on loop with one click",
77
"icons": {
88
"19": "icons/icon_19px.png",

0 commit comments

Comments
 (0)