Skip to content

Commit

Permalink
Avoid skip button conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ConfusedPolarBear committed Mar 14, 2023
1 parent 2b26fa1 commit 43830fb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ConfusedPolarBear.Plugin.IntroSkipper/Configuration/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ introSkipper.injectCss = function () {
* Calling this function is a no-op if the CSS has already been injected.
*/
introSkipper.injectButton = async function () {
if (introSkipper.testElement(".btnSkipIntro")) {
// Ensure the button we're about to inject into the page doesn't conflict with a pre-existing one
const preExistingButton = introSkipper.testElement("div.skipIntro");
if (preExistingButton) {
preExistingButton.style.display = "none";
}

if (introSkipper.testElement(".btnSkipIntro.injected")) {
introSkipper.d("Button already added");
return;
}
Expand All @@ -155,7 +161,7 @@ introSkipper.injectButton = async function () {
button.classList.add("hide");
button.addEventListener("click", introSkipper.doSkip);
button.innerHTML = `
<button is="paper-icon-button-light" class="btnSkipIntro paper-icon-button-light">
<button is="paper-icon-button-light" class="btnSkipIntro paper-icon-button-light injected">
<span id="btnSkipSegmentText"></span>
<span class="material-icons skip_next"></span>
</button>
Expand Down

0 comments on commit 43830fb

Please sign in to comment.