Skip to content

Commit

Permalink
Merge pull request #70 from VampireChicken12/dev
Browse files Browse the repository at this point in the history
fix: Forgot to enable hide scrollbar on page load
  • Loading branch information
VampireChicken12 authored Nov 4, 2023
2 parents 1bc1dda + 1d9b793 commit 9c69bcc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
31 changes: 15 additions & 16 deletions src/features/hideScrollBar/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
export function hideScrollBar() {
const style = document.createElement("style");
style.innerHTML = `
::-webkit-scrollbar {
width: 0px;
height: 0px;
}
`;
style.id = "yte-hide-scroll-bar";
document.head.appendChild(style);
}
export function showScrollBar() {
const style = document.getElementById("yte-hide-scroll-bar");
if (style) {
style.remove();
}
import { waitForSpecificMessage } from "@/src/utils/utilities";
import { hideScrollBar } from "./utils";

export async function enableHideScrollBar() {
// Wait for the "options" message from the content script
const optionsData = await waitForSpecificMessage("options", "request_data", "content");
if (!optionsData) return;
const {
data: { options }
} = optionsData;
// Extract the necessary properties from the options object
const { enable_hide_scroll_bar } = options;
// If the hide scroll bar option is disabled, return
if (!enable_hide_scroll_bar) return;
hideScrollBar();
}
17 changes: 17 additions & 0 deletions src/features/hideScrollBar/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export function hideScrollBar() {
const style = document.createElement("style");
style.innerHTML = `
::-webkit-scrollbar {
width: 0px;
height: 0px;
}
`;
style.id = "yte-hide-scroll-bar";
document.head.appendChild(style);
}
export function showScrollBar() {
const style = document.getElementById("yte-hide-scroll-bar");
if (style) {
style.remove();
}
}
4 changes: 3 additions & 1 deletion src/pages/content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import eventManager from "@/utils/EventManager";
import { browserColorLog, formatError } from "@/utils/utilities";

import type { ExtensionSendOnlyMessageMappings, Messages, YouTubePlayerDiv } from "@/src/types";
import { hideScrollBar, showScrollBar } from "@/src/features/hideScrollBar";
import { enableHideScrollBar } from "@/src/features/hideScrollBar";
import { hideScrollBar, showScrollBar } from "@/src/features/hideScrollBar/utils";
// TODO: Add always show progressbar feature

// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down Expand Up @@ -68,6 +69,7 @@ document.documentElement.appendChild(element);
window.onload = function () {
enableRememberVolume();
enableFeatureMenu();
enableHideScrollBar();
const enableFeatures = () => {
eventManager.removeAllEventListeners(["featureMenu"]);
addLoopButton();
Expand Down

0 comments on commit 9c69bcc

Please sign in to comment.