Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update functions.js fix Repeat button display #2085

Closed
wants to merge 13 commits into from
4 changes: 0 additions & 4 deletions js&css/extension/www.youtube.com/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,6 @@ ytd-guide-section-renderer .it-button::after {
fill: var(--yt-spec-icon-inactive);
}

.improvedtube-player-button:last-of-type {
margin-right: 24px;
}

.improvedtube-player-button:hover::after {
position: absolute;
top: 150%;
Expand Down
29 changes: 19 additions & 10 deletions js&css/web-accessible/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,24 @@ document.addEventListener('it-message-from-extension', function () {
if (rightControls) {
rightControls.style.setProperty('padding-right', ''); // Restoring the original padding:
rightControls.style.setProperty('display', 'flex'); } }
} else if ( camelized_key === 'belowPlayerPip' ){
if (ImprovedTube.storage.below_player_pip === false) { document.querySelector('.improvedtube-player-button[data-tooltip="PiP"]')?.remove();}
if (ImprovedTube.storage.below_player_pip === true) { document.querySelectorAll('.improvedtube-player-button').forEach(e => e.remove()); ImprovedTube.improvedtubeYoutubeButtonsUnderPlayer(); }
} else if ( camelized_key === 'belowPlayerScreenshot' ){
if (ImprovedTube.storage.below_player_screenshot === false) { document.querySelector('.improvedtube-player-button[data-tooltip="Screenshot"]')?.remove();}
if (ImprovedTube.storage.below_player_screenshot === true) { document.querySelectorAll('.improvedtube-player-button').forEach(e => e.remove());; ImprovedTube.improvedtubeYoutubeButtonsUnderPlayer(); }
} else if ( camelized_key === 'belowPlayerLoop' ){
if (ImprovedTube.storage.below_player_loop === false) { document.querySelector('.improvedtube-player-button[data-tooltip="Loop"]')?.remove();}
if (ImprovedTube.storage.below_player_loop === true) { document.querySelectorAll('.improvedtube-player-button').forEach(e => e.remove()); ImprovedTube.improvedtubeYoutubeButtonsUnderPlayer(); }
} else if (camelized_key === 'belowPlayerPip' ) {
if (ImprovedTube.storage.below_player_pip) {
ImprovedTube.improvedtubeYoutubeButtonsUnderPlayer();
} else {
document.getElementById('it-below-player-pip')?.remove();
}
} else if (camelized_key === 'belowPlayerScreenshot' ) {
if (ImprovedTube.storage.below_player_screenshot) {
ImprovedTube.improvedtubeYoutubeButtonsUnderPlayer();
} else {
document.getElementById('it-below-player-screenshot')?.remove();
}
} else if (camelized_key === 'belowPlayerLoop' ) {
if (ImprovedTube.storage.below_player_loop) {
ImprovedTube.improvedtubeYoutubeButtonsUnderPlayer();
} else {
document.getElementById('it-below-player-loop')?.remove();
}
} else if ( camelized_key === 'dayOfWeek') {
if (ImprovedTube.storage.day_of_week === false) { document.querySelector(".ytd-day-of-week")?.remove(); }
if (ImprovedTube.storage.day_of_week === true) { ImprovedTube.dayOfWeek(); }
Expand Down Expand Up @@ -330,4 +339,4 @@ ImprovedTube.messages.send = function (message) {

document.dispatchEvent(new CustomEvent('it-message-from-youtube'));
}
};
};
29 changes: 27 additions & 2 deletions js&css/web-accessible/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,9 @@ ImprovedTube.videoPageUpdate = function () {
ImprovedTube.upNextAutoplay();
ImprovedTube.playerAutofullscreen();
ImprovedTube.playerSize();
if( this.storage.player_always_repeat === true) {ImprovedTube.playerRepeat();};
ImprovedTube.playerScreenshotButton();
ImprovedTube.playerRepeatButton();
ImprovedTube.playerAlwaysRepeat();
ImprovedTube.playerRotateButton();
ImprovedTube.playerPopupButton();
ImprovedTube.playerFitToWinButton();
Expand Down Expand Up @@ -354,9 +354,9 @@ ImprovedTube.initPlayer = function () {
ImprovedTube.subtitlesBackgroundOpacity();
ImprovedTube.playerQuality();
ImprovedTube.playerVolume();
if(this.storage.player_always_repeat === true) {ImprovedTube.playerRepeat();};
ImprovedTube.playerScreenshotButton();
ImprovedTube.playerRepeatButton();
ImprovedTube.playerAlwaysRepeat();
ImprovedTube.playerRotateButton();
ImprovedTube.playerPopupButton();
ImprovedTube.playerFitToWinButton();
Expand Down Expand Up @@ -558,6 +558,31 @@ ImprovedTube.createPlayerButton = function (options) {
controls.insertBefore(button, controls.childNodes[3]);
}
};

ImprovedTube.createUnderPlayerButton = function (options) {
var section = document.getElementById('subscribe-button');

if (section) {
let button = document.createElement('button'),
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', options.path);
svg.style.opacity = options.opacity;
svg.appendChild(path);

button.appendChild(svg);
button.className = 'improvedtube-player-button';
button.style = options.style;
button.dataset.tooltip = options.tooltip;
button.id = options.id;
button.onclick = options.onclick;

section.insertAdjacentElement('afterend', button);
}
};

ImprovedTube.empty = function (element) {for (var i = element.childNodes.length - 1; i > -1; i--) { element.childNodes[i].remove(); }};
ImprovedTube.isset = function (variable) { return !(typeof variable === 'undefined' || variable === null || variable === 'null');};
ImprovedTube.stopPropagation = function (event) { event.stopPropagation(); };
Expand Down
Loading