Skip to content

Commit

Permalink
repeat & always repeat #1504 #1990
Browse files Browse the repository at this point in the history
  • Loading branch information
ImprovedTube authored Feb 8, 2024
1 parent c770051 commit fd9dec9
Showing 1 changed file with 20 additions and 30 deletions.
50 changes: 20 additions & 30 deletions js&css/web-accessible/www.youtube.com/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,33 +671,40 @@ ImprovedTube.playerScreenshotButton = function () {
}
};
/*------------------------------------------------------------------------------
REPEAT ALWAYS
-------------------------------------------------------------------------------*/
ImprovedTube.playerAlwaysRepeat = function () {
if (this.storage.player_always_repeat === true) {
setTimeout(function () {
ImprovedTube.elements.video.setAttribute('loop', '');
//old from version 3.x? // ImprovedTube.elements.buttons['it-repeat-styles'].style.opacity = '1';
}, 300);
}
}
/*------------------------------------------------------------------------------
REPEAT
------------------------------------------------------------------------------*/
ImprovedTube.playerRepeatButton = function (node) {
if (this.storage.player_repeat_button === true) {
var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'),
path = document.createElementNS('http://www.w3.org/2000/svg', 'path');

svg.setAttributeNS(null, 'viewBox', '0 0 24 24');
path.setAttributeNS(null, 'd', 'M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4zm-4-2V9h-1l-2 1v1h1.5v4H13z');
svg.appendChild(path);

function matchLoopState(opacity) {
if (ImprovedTube.storage.below_player_loop !== false) {
var otherButton = document.querySelector('#it-below-player-loop');
otherButton.children[0].style.opacity = opacity;
}
svg.style.opacity = opacity;
}

var transparentOrOn = 0.5; if (this.storage.player_always_repeat === true ) { transparentOrOn = 1; }
this.createPlayerButton({
id: 'it-repeat-button',
child: svg,
opacity: 1,
opacity: transparentOrOn,
onclick: function () {
var video = ImprovedTube.elements.video;

if (video.hasAttribute('loop')) {
function matchLoopState(opacity) {
svg.style.opacity = opacity;
if (ImprovedTube.storage.below_player_loop !== false) {
var otherButton = document.querySelector('#it-below-player-loop');
otherButton.children[0].style.opacity = opacity;
}
} if (video.hasAttribute('loop')) {
video.removeAttribute('loop');
matchLoopState('.5')
} else if (!/ad-showing/.test(ImprovedTube.elements.player.className)) {
Expand All @@ -707,23 +714,6 @@ ImprovedTube.playerRepeatButton = function (node) {
},
title: 'Repeat',
});
if(ImprovedTube.storage.below_player_loop !== false) {
var otherButton = document.querySelector('#it-below-player-loop');
if (document.querySelector('#it-below-player-loop').style.opacity === '1') {
matchLoopState('1');
if (!video.hasAttribute('loop')) {
video.setAttribute('loop', '');
}
}
}

if (this.storage.player_always_repeat === true) {
setTimeout(function () {
ImprovedTube.elements.video.setAttribute('loop', '');
ImprovedTube.elements.buttons['it-repeat-styles'].style.opacity = '1';
matchLoopState('1');
}, 100);
}
}
};
/*------------------------------------------------------------------------------
Expand Down

0 comments on commit fd9dec9

Please sign in to comment.