Skip to content

Commit 8b134d1

Browse files
authored
Merge pull request #3268 from tylerking999/fix-duplicate-buttons
Fix: Prevent duplicate player buttons on video navigation -Added uniq…
2 parents 0ab431d + efd12e0 commit 8b134d1

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

js&css/web-accessible/www.youtube.com/appearance.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,8 @@ ImprovedTube.improvedtubeYoutubeButtonsUnderPlayer = function () {
408408
|| this.storage.description == "classic_expanded" || this.storage.description == "classic_hidden" )
409409
{var section = document.querySelector('#flex.ytd-video-primary-info-renderer');}
410410
*/
411-
if (section && !section.querySelector('.improvedtube-player-button')) {
412-
if (this.storage.below_player_loop !== false) {
411+
if (section) {
412+
if (this.storage.below_player_loop !== false && !document.querySelector('#it-below-player-loop')) {
413413
var button = document.createElement('button'),
414414
svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'),
415415
path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
@@ -444,12 +444,13 @@ ImprovedTube.improvedtubeYoutubeButtonsUnderPlayer = function () {
444444
svg.appendChild(path); button.appendChild(svg);
445445
section.insertAdjacentElement('afterend', button)
446446
}
447-
if (this.storage.below_player_pip !== false) {
447+
if (this.storage.below_player_pip !== false && !document.querySelector('#it-below-player-pip')) {
448448
var button = document.createElement('button'),
449449
svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'),
450450
path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
451451

452452
button.className = 'improvedtube-player-button';
453+
button.id = 'it-below-player-pip';
453454
button.dataset.tooltip = 'PiP';
454455
svg.style.opacity = '.64';
455456
svg.setAttributeNS(null, 'viewBox', '0 0 24 24');
@@ -463,12 +464,13 @@ ImprovedTube.improvedtubeYoutubeButtonsUnderPlayer = function () {
463464
section.insertAdjacentElement('afterend', button)
464465
}
465466

466-
if (this.storage.below_player_screenshot !== false) {
467+
if (this.storage.below_player_screenshot !== false && !document.querySelector('#it-below-player-screenshot')) {
467468
var button = document.createElement('button'),
468469
svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'),
469470
path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
470471

471472
button.className = 'improvedtube-player-button';
473+
button.id = 'it-below-player-screenshot';
472474
button.dataset.tooltip = 'Screenshot';
473475
svg.style.opacity = '.55';
474476
svg.setAttributeNS(null, 'viewBox', '0 0 24 24');
@@ -480,13 +482,14 @@ ImprovedTube.improvedtubeYoutubeButtonsUnderPlayer = function () {
480482
section.insertAdjacentElement('afterend', button)
481483
}
482484

483-
if (this.storage.below_player_keyscene !== false) {
485+
if (this.storage.below_player_keyscene !== false && !document.querySelector('#it-below-player-keyscene')) {
484486
var button = document.createElement('button'),
485487
svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'),
486488
g = document.createElementNS('http://www.w3.org/2000/svg', 'g'),
487489
path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
488490

489491
button.className = 'improvedtube-player-button';
492+
button.id = 'it-below-player-keyscene';
490493
button.style.marginRight = '-0.2px';
491494
button.dataset.tooltip = 'Key Scene';
492495
svg.style.opacity = '.55';
@@ -507,12 +510,13 @@ ImprovedTube.improvedtubeYoutubeButtonsUnderPlayer = function () {
507510

508511
let copyVideoUrlButton = this.storage.copy_video_url === true;
509512

510-
if (this.storage.copy_video_id === true) {
513+
if (this.storage.copy_video_id === true && !document.querySelector('#it-below-player-copy-video-id')) {
511514
var button = document.createElement('button'),
512515
svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'),
513516
path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
514517

515518
button.className = 'improvedtube-player-button';
519+
button.id = 'it-below-player-copy-video-id';
516520
button.dataset.tooltip = 'CopyVideoId';
517521
svg.style.opacity = '.5';
518522
svg.setAttributeNS(null, 'viewBox', '0 0 24 24');

0 commit comments

Comments
 (0)