Skip to content

Commit 56ee22a

Browse files
author
bliss
committed
Prevents display of multiple control buttons when other video is selected.
1 parent d99da6e commit 56ee22a

File tree

3 files changed

+39
-31
lines changed

3 files changed

+39
-31
lines changed

dist/content.js

+22-18
Original file line numberDiff line numberDiff line change
@@ -86821,27 +86821,31 @@ function loadImage() {
8682186821

8682286822
mainVideo.addEventListener('loadeddata', function (event) {
8682386823
var animControlsButton = document.getElementsByClassName("ytp-right-controls");
86824-
var button = document.createElement('button');
86825-
button.className = 'ytp-button it-player-button';
86826-
button.dataset.title = "PoseDream";
8682786824

86828-
button.onclick = function () {
86829-
document.dispatchEvent(new CustomEvent('displayPoseDreamPopup', {
86830-
detail: {
86831-
animationID: 'skeleton'
86832-
}
86833-
}));
86834-
};
86825+
if (document.getElementById("posedream-popup-btn") === null) {
86826+
var button = document.createElement('button');
86827+
button.id = "posedream-popup-btn";
86828+
button.className = 'ytp-button it-player-button';
86829+
button.dataset.title = "PoseDream";
86830+
86831+
button.onclick = function () {
86832+
document.dispatchEvent(new CustomEvent('displayPoseDreamPopup', {
86833+
detail: {
86834+
animationID: 'skeleton'
86835+
}
86836+
}));
86837+
};
8683586838

86836-
animControlsButton[0].insertBefore(button, animControlsButton[0].childNodes[0]);
86837-
var playerImage = new Image();
86838-
playerImage.src = chrome.runtime.getURL("/images/logo48.png");
86839+
animControlsButton[0].insertBefore(button, animControlsButton[0].childNodes[0]);
86840+
var playerImage = new Image();
86841+
playerImage.src = chrome.runtime.getURL("/images/logo48.png");
8683986842

86840-
playerImage.onload = function () {
86841-
var imgTag = document.createElement('img');
86842-
imgTag.src = playerImage.src;
86843-
button.appendChild(imgTag);
86844-
};
86843+
playerImage.onload = function () {
86844+
var imgTag = document.createElement('img');
86845+
imgTag.src = playerImage.src;
86846+
button.appendChild(imgTag);
86847+
};
86848+
}
8684586849

8684686850
var div = document.createElement('div');
8684786851
div.className = 'posedream-video-popup';

dist/content.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/content.js

+16-12
Original file line numberDiff line numberDiff line change
@@ -910,20 +910,24 @@ function loadImage() {
910910
mainVideo.addEventListener('loadeddata', (event) => {
911911

912912
var animControlsButton = document.getElementsByClassName("ytp-right-controls");
913-
var button = document.createElement('button');
914-
button.className = 'ytp-button it-player-button';
915-
button.dataset.title = "PoseDream";
916-
button.onclick = function(){document.dispatchEvent(new CustomEvent('displayPoseDreamPopup', { detail: {animationID:'skeleton'} }));}
917-
animControlsButton[0].insertBefore(button, animControlsButton[0].childNodes[0]);
918-
919-
let playerImage = new Image();
920-
playerImage.src = chrome.runtime.getURL("/images/logo48.png");
921-
playerImage.onload = () => {
922-
var imgTag = document.createElement('img');
923-
imgTag.src=playerImage.src;
924-
button.appendChild(imgTag);
913+
if(document.getElementById("posedream-popup-btn") === null){
914+
var button = document.createElement('button');
915+
button.id="posedream-popup-btn";
916+
button.className = 'ytp-button it-player-button';
917+
button.dataset.title = "PoseDream";
918+
button.onclick = function(){document.dispatchEvent(new CustomEvent('displayPoseDreamPopup', { detail: {animationID:'skeleton'} }));}
919+
animControlsButton[0].insertBefore(button, animControlsButton[0].childNodes[0]);
920+
921+
let playerImage = new Image();
922+
playerImage.src = chrome.runtime.getURL("/images/logo48.png");
923+
playerImage.onload = () => {
924+
var imgTag = document.createElement('img');
925+
imgTag.src=playerImage.src;
926+
button.appendChild(imgTag);
927+
}
925928
}
926929

930+
927931
const div = document.createElement('div');
928932

929933
div.className = 'posedream-video-popup';

0 commit comments

Comments
 (0)