diff --git a/src/contents/content-script-support.svelte b/src/contents/content-script-support.svelte
new file mode 100644
index 0000000..f5d3073
--- /dev/null
+++ b/src/contents/content-script-support.svelte
@@ -0,0 +1,81 @@
+
+
+
+
+{#if !isHideDonationSection}
+
+
+
+ Hi there,
+
+ If you've been enjoying this extension, you might be interested to know that maintaining this project requires
+ both time and resources. Your support can make a significant difference.
+
+
+ To continue offering you a high-quality experience, a donation via PayPal would be greatly appreciated. These contributions go directly into maintaining
+ and improving this and future projects.
+
+
+ Thank you for your time and for considering this request. Your support helps keep it up and running.
+
+
+{/if}
diff --git a/src/contents/content-script-support.ts b/src/contents/content-script-support.ts
deleted file mode 100644
index fa127b9..0000000
--- a/src/contents/content-script-support.ts
+++ /dev/null
@@ -1,111 +0,0 @@
-import { Storage } from "@plasmohq/storage";
-import textStyle from "data-text:~cs-helpers/desktop/injected-style.scss";
-import type { PlasmoCSConfig } from "plasmo";
-
-import {
- OBSERVER_OPTIONS,
- SELECTORS,
- addGlobalEventListener,
- getIsExtensionEnabled,
- getVisibleElement
-} from "~shared-scripts/ythd-utils";
-
-const storageSync = new Storage({ area: "sync" });
-let gObserverNavigation: MutationObserver;
-
-let gTitleLast = document.title;
-let gUrlLast = location.href;
-let gElSupportSection: HTMLElement;
-
-function addSupportButtonIfNeeded(): void {
- const elContainer = getVisibleElement(SELECTORS.relatedVideos);
- gElSupportSection = getVisibleElement(SELECTORS.donationSection);
- if (!elContainer || gElSupportSection) {
- return;
- }
-
- const CLASS_DONATION = SELECTORS.donationSection.substring(1);
- gElSupportSection = document.createElement("article");
- gElSupportSection.classList.add(CLASS_DONATION);
- gElSupportSection.innerHTML = `
-
-
- Hi there,
-
-
- If you've been enjoying this extension, you might be interested to know that maintaining this project requires both time and resources. Your support can make a significant difference.
-
-
- To continue offering you a high-quality experience, a donation via PayPal would be greatly appreciated. These contributions go directly into maintaining and improving this and future projects.
-
-
- Thank you for your time and for considering this request. Your support helps keep it up and running.
-
- `;
- gElSupportSection.addEventListener("click", async ({ target }) => {
- const element = target as HTMLElement;
- if (element.matches("button, a[href*=paypal]")) {
- // If clicking either the close button or the link, this section will be permanently closed
- // Clicking the link will also open the donation link in a new tab
- await storageSync.set("isHideDonationSection", true);
- }
- });
- elContainer.prepend(gElSupportSection);
-}
-
-async function addTemporaryBodyListener(): Promise {
- if (gTitleLast === document.title || gUrlLast === location.href || !(await getIsExtensionEnabled())) {
- return;
- }
-
- gTitleLast = document.title;
- gUrlLast = location.href;
-
- addSupportButtonIfNeeded();
-}
-
-function injectStyles(): void {
- const elStyle = document.createElement("style");
- elStyle.textContent = textStyle;
- document.head.append(elStyle);
-}
-
-async function init(): Promise {
- const isHideDonationSection = await storageSync.get("isHideDonationSection");
- if (isHideDonationSection) {
- return;
- }
-
- injectStyles();
- gObserverNavigation = await addGlobalEventListener(addTemporaryBodyListener);
-
- // When the user visits a /watch page, the support button
- // will be added if the user hasn't clicked on one yet
- new MutationObserver(async (_, observer) => {
- const elContainer = getVisibleElement(SELECTORS.relatedVideos);
- if (!(await getIsExtensionEnabled()) || !elContainer) {
- return;
- }
-
- observer.disconnect();
-
- addSupportButtonIfNeeded();
- }).observe(document, OBSERVER_OPTIONS);
-
- storageSync.watch({
- isHideDonationSection() {
- gObserverNavigation.disconnect();
- gElSupportSection?.remove();
- }
- });
-}
-
-init();
-
-export const config: PlasmoCSConfig = {
- matches: ["https://www.youtube.com/*"]
-};