Skip to content

Commit

Permalink
Merge pull request #86 from VampireChicken12/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
VampireChicken12 authored Nov 14, 2023
2 parents 40193ce + d21d326 commit c7cbb96
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/@types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export type RequestDataMessage<Type extends string, D> = Prettify<
>;
export type ContentSendOnlyMessageMappings = {
setRememberedVolume: SendDataMessage<"send_data", "content", "setRememberedVolume", { shortsPageVolume?: number; watchPageVolume?: number }>;
pageLoaded: SendDataMessage<"send_data", "content", "pageLoaded", undefined>;
};
export type ExtensionSendOnlyMessageMappings = {
volumeBoostChange: DataResponseMessage<"volumeBoostChange", { volumeBoostEnabled: boolean; volumeBoostAmount?: number }>;
Expand Down
3 changes: 3 additions & 0 deletions src/features/hideScrollBar/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export function hideScrollBar() {
width: 0px;
height: 0px;
}
html {
scrollbar-width: none;
}
`;
style.id = "yte-hide-scroll-bar";
document.head.appendChild(style);
Expand Down
8 changes: 7 additions & 1 deletion src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ const manifestV2: Manifest.WebExtensionManifest = {
"src/pages/content/index.js",
"src/pages/inject/index.js",
...availableLocales.map((locale) => `/locales/${locale}.json`)
]
],
browser_specific_settings: {
gecko: {
id: "{c49b13b1-5dee-4345-925e-0c793377e3fa}",
strict_min_version: "48.0"
}
}
};

export { manifestV3, manifestV2 };
3 changes: 2 additions & 1 deletion src/pages/content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import adjustVolumeOnScrollWheel from "@/src/features/scrollWheelVolumeControl";
import { promptUserToResumeVideo, setupVideoHistory } from "@/src/features/videoHistory";
import volumeBoost from "@/src/features/volumeBoost";
import eventManager from "@/utils/EventManager";
import { browserColorLog, formatError, waitForSpecificMessage } from "@/utils/utilities";
import { browserColorLog, formatError, sendContentOnlyMessage, waitForSpecificMessage } from "@/utils/utilities";

import type { ExtensionSendOnlyMessageMappings, Messages, YouTubePlayerDiv } from "@/src/@types";
import { enableHideScrollBar } from "@/src/features/hideScrollBar";
Expand Down Expand Up @@ -275,6 +275,7 @@ window.onload = async function () {
}
}
});
sendContentOnlyMessage("pageLoaded", undefined);
};
window.onbeforeunload = function () {
eventManager.removeAllEventListeners();
Expand Down
12 changes: 6 additions & 6 deletions src/pages/inject/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ document.documentElement.appendChild(script);
});
sendExtensionMessage("options", "data_response", { options });
})();
window.onload = () => {
chrome.storage.onChanged.addListener(storageListeners);
};
window.onunload = () => {
chrome.storage.onChanged.removeListener(storageListeners);
};

/**
* Listens for the "yte-message-from-youtube" event and handles incoming messages from the YouTube page.
Expand Down Expand Up @@ -126,6 +120,12 @@ document.addEventListener("yte-message-from-youtube", async () => {
});
break;
}
case "pageLoaded": {
chrome.storage.onChanged.addListener(storageListeners);
window.onunload = () => {
chrome.storage.onChanged.removeListener(storageListeners);
};
}
}
});
const storageListeners = async (changes: StorageChanges, areaName: string) => {
Expand Down

0 comments on commit c7cbb96

Please sign in to comment.