From 43830fbc13a21f8cdeaf188b6adadf4b481965be Mon Sep 17 00:00:00 2001 From: ConfusedPolarBear <33811686+ConfusedPolarBear@users.noreply.github.com> Date: Mon, 13 Mar 2023 21:00:21 -0500 Subject: [PATCH] Avoid skip button conflicts --- .../Configuration/inject.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/inject.js b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/inject.js index 69b7d3c..75c013e 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/inject.js +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/inject.js @@ -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; } @@ -155,7 +161,7 @@ introSkipper.injectButton = async function () { button.classList.add("hide"); button.addEventListener("click", introSkipper.doSkip); button.innerHTML = ` -