Skip to content

Commit

Permalink
Update popup.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ApeDevOne authored Sep 23, 2024
1 parent dd7f11a commit cda2063
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,33 @@ document.addEventListener('DOMContentLoaded', () => {
});
});



function changeSubtitleStyle(size, font, opacity) {
const textContainer = document.querySelector('.shaka-text-container');
if (textContainer) {
const observer = new MutationObserver(() => {
const textRegions = document.querySelectorAll('.shaka-text-region');
textRegions.forEach(region => {
const textSpans = region.querySelectorAll('span span');
textSpans.forEach(span => {
span.classList.add('custom-subtitle-style');
});
const observer = new MutationObserver(() => {
const textContainers = document.querySelectorAll('div[class^="mui-style-"][class$="-subtitlesContainer"]');
textContainers.forEach(container => {
const textSpans = container.querySelectorAll('span');
textSpans.forEach(span => {
span.classList.add('custom-subtitle-style');
});
const style = document.createElement('style');
style.innerHTML = `
.shaka-text-region span span.custom-subtitle-style {
font-size: ${size}px !important;
font-family: ${font} !important;
background-color: rgba(0, 0, 0, ${opacity}) !important;
}
`;
document.head.appendChild(style);
});
observer.observe(textContainer, { childList: true, subtree: true });

const style = document.createElement('style');
style.innerHTML = `
div[class^="mui-style-"][class$="-subtitlesContainer"] span.custom-subtitle-style {
font-size: ${size}px !important;
font-family: ${font} !important;
background-color: rgba(0, 0, 0, ${opacity}) !important;
}
`;
document.head.appendChild(style);
});

const subtitleContainer = document.querySelector('#subtitle-1');
if (subtitleContainer) {
observer.observe(subtitleContainer, { childList: true, subtree: true });
}
}


0 comments on commit cda2063

Please sign in to comment.