Skip to content

Commit 4135bf2

Browse files
committed
2 parents f9d1415 + 632b55d commit 4135bf2

14 files changed

Lines changed: 2550 additions & 2143 deletions

File tree

bun.lockb

70.1 KB
Binary file not shown.

package-lock.json

Lines changed: 2464 additions & 2053 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"react-icons": "^5.0.1",
3333
"use-debouncy": "^5.0.1",
3434
"vite-plugin-css-injected-by-js": "^3.3.0",
35-
"webextension-polyfill": "^0.10.0"
35+
"webextension-polyfill": "^0.11.0"
3636
},
3737
"devDependencies": {
3838
"@semantic-release/changelog": "^6.0.3",
@@ -48,7 +48,7 @@
4848
"@types/webextension-polyfill": "^0.10.6",
4949
"@types/youtube-player": "^5.5.10",
5050
"@typescript-eslint/eslint-plugin": "^7.0.0",
51-
"@typescript-eslint/parser": "^6.10.0",
51+
"@typescript-eslint/parser": "^7.7.0",
5252
"@vitejs/plugin-react-swc": "^3.4.1",
5353
"archiver": "^7.0.1",
5454
"autoprefixer": "^10.4.16",

src/components/Inputs/CSSEditor/CSSEditor.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,8 @@ const CSSEditor: React.FC<CSSEditorProps> = ({ className, id, onChange, value })
139139
<ExpandButton
140140
isExpanded={isEditorExpanded}
141141
onToggle={() => {
142-
if (!isEditorExpanded) {
143-
expandEditor();
144-
} else {
145-
collapseEditor();
146-
}
142+
if (!isEditorExpanded) return expandEditor();
143+
collapseEditor();
147144
}}
148145
ref={expandButtonRef}
149146
/>

src/components/Inputs/Number/Number.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const NumberInput: React.FC<NumberInputProps> = ({ className, disabled, id, labe
8383
value={value}
8484
></input>
8585
<div
86-
className={cn("absolute bottom-[1px] flex h-[38px] flex-col", {
86+
className={cn("absolute bottom-px flex h-[38px] flex-col", {
8787
"left-[1px]": direction === "rtl",
8888
"right-[1px]": direction === "ltr"
8989
})}

src/components/Settings/Settings.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,42 +230,42 @@ export default function Settings() {
230230
];
231231
const colorOptions: SelectOption<"osd_display_color">[] = [
232232
{
233-
element: <div className={cn("m-2 size-3 rounded-[50%] border-[1px] border-solid border-black", "bg-[red]")}></div>,
233+
element: <div className={cn("m-2 size-3 rounded-[50%] border-DEFAULT border-solid border-black", "bg-[red]")}></div>,
234234
label: t("settings.sections.onScreenDisplaySettings.color.options.red"),
235235
value: "red"
236236
},
237237
{
238-
element: <div className={cn("m-2 size-3 rounded-[50%] border-[1px] border-solid border-black", "bg-[green]")}></div>,
238+
element: <div className={cn("m-2 size-3 rounded-[50%] border-DEFAULT border-solid border-black", "bg-[green]")}></div>,
239239
label: t("settings.sections.onScreenDisplaySettings.color.options.green"),
240240
value: "green"
241241
},
242242
{
243-
element: <div className={cn("m-2 size-3 rounded-[50%] border-[1px] border-solid border-black", "bg-[blue]")}></div>,
243+
element: <div className={cn("m-2 size-3 rounded-[50%] border-DEFAULT border-solid border-black", "bg-[blue]")}></div>,
244244
label: t("settings.sections.onScreenDisplaySettings.color.options.blue"),
245245
value: "blue"
246246
},
247247
{
248-
element: <div className={cn("m-2 size-3 rounded-[50%] border-[1px] border-solid border-black", "bg-[yellow]")}></div>,
248+
element: <div className={cn("m-2 size-3 rounded-[50%] border-DEFAULT border-solid border-black", "bg-[yellow]")}></div>,
249249
label: t("settings.sections.onScreenDisplaySettings.color.options.yellow"),
250250
value: "yellow"
251251
},
252252
{
253-
element: <div className={cn("m-2 size-3 rounded-[50%] border-[1px] border-solid border-black", "bg-[orange]")}></div>,
253+
element: <div className={cn("m-2 size-3 rounded-[50%] border-DEFAULT border-solid border-black", "bg-[orange]")}></div>,
254254
label: t("settings.sections.onScreenDisplaySettings.color.options.orange"),
255255
value: "orange"
256256
},
257257
{
258-
element: <div className={cn("m-2 size-3 rounded-[50%] border-[1px] border-solid border-black", "bg-[purple]")}></div>,
258+
element: <div className={cn("m-2 size-3 rounded-[50%] border-DEFAULT border-solid border-black", "bg-[purple]")}></div>,
259259
label: t("settings.sections.onScreenDisplaySettings.color.options.purple"),
260260
value: "purple"
261261
},
262262
{
263-
element: <div className={cn("m-2 size-3 rounded-[50%] border-[1px] border-solid border-black", "bg-[pink]")}></div>,
263+
element: <div className={cn("m-2 size-3 rounded-[50%] border-DEFAULT border-solid border-black", "bg-[pink]")}></div>,
264264
label: t("settings.sections.onScreenDisplaySettings.color.options.pink"),
265265
value: "pink"
266266
},
267267
{
268-
element: <div className={cn("m-2 size-3 rounded-[50%] border-[1px] border-solid border-black", "bg-[white]")}></div>,
268+
element: <div className={cn("m-2 size-3 rounded-[50%] border-DEFAULT border-solid border-black", "bg-[white]")}></div>,
269269
label: t("settings.sections.onScreenDisplaySettings.color.options.white"),
270270
value: "white"
271271
}

src/components/Settings/components/SettingNotifications.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useSettings } from "../Settings";
88
function NotificationCloseButton({ notification }: { notification: Notification }) {
99
const { removeNotification } = useNotifications();
1010
return (
11-
<button className="absolute right-[5px] top-[-1px] text-base font-normal" onClick={() => removeNotification(notification)}>
11+
<button className="absolute -top-px right-[5px] text-base font-normal" onClick={() => removeNotification(notification)}>
1212
&times;
1313
</button>
1414
);

src/defaults.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,30 @@ function setDefaultValues() {
1515
localStorage.setItem(option, typeof defaultValue === "string" ? defaultValue : JSON.stringify(defaultValue));
1616
// Set the default value in chrome storage
1717
void chrome.storage.local.set({ [option]: defaultValue });
18-
} else {
19-
try {
20-
// Parse the stored value to check its type
21-
const storedValue =
22-
(
23-
typeof defaultConfiguration[option] === "object" ||
24-
typeof defaultConfiguration[option] === "boolean" ||
25-
typeof defaultConfiguration[option] === "number"
26-
) ?
27-
JSON.parse(storedValueString)
28-
: storedValueString;
29-
// Check if the parsed value is an object and has properties
30-
if (typeof storedValue === "object" && storedValue !== null) {
31-
// Deep merge missing keys with their default values
32-
const updatedValue = deepMerge(defaultValue as Record<string, unknown>, storedValue as Record<string, unknown>);
33-
// Set the updated value in localStorage
34-
localStorage.setItem(option, JSON.stringify(updatedValue));
35-
// Set the updated value in chrome storage
36-
void chrome.storage.local.set({ [option]: updatedValue });
37-
}
38-
} catch (error) {
39-
// Handle errors during JSON parsing
40-
console.error(`Error parsing stored value for option ${option}:`, error);
18+
continue;
19+
}
20+
try {
21+
// Parse the stored value to check its type
22+
const storedValue =
23+
(
24+
typeof defaultConfiguration[option] === "object" ||
25+
typeof defaultConfiguration[option] === "boolean" ||
26+
typeof defaultConfiguration[option] === "number"
27+
) ?
28+
JSON.parse(storedValueString)
29+
: storedValueString;
30+
// Check if the parsed value is an object and has properties
31+
if (typeof storedValue === "object" && storedValue !== null) {
32+
// Deep merge missing keys with their default values
33+
const updatedValue = deepMerge(defaultValue as Record<string, unknown>, storedValue as Record<string, unknown>);
34+
// Set the updated value in localStorage
35+
localStorage.setItem(option, JSON.stringify(updatedValue));
36+
// Set the updated value in chrome storage
37+
void chrome.storage.local.set({ [option]: updatedValue });
4138
}
39+
} catch (error) {
40+
// Handle errors during JSON parsing
41+
console.error(`Error parsing stored value for option ${option}:`, error);
4242
}
4343
}
4444
}

src/features/buttonPlacement/utils.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,14 @@ function buttonClickListener<Placement extends ButtonPlacement, Name extends All
1212
listener: ListenerType<Toggle>,
1313
isToggle: boolean
1414
) {
15-
if (isToggle) {
16-
button.ariaChecked = button.ariaChecked ? (!JSON.parse(button.ariaChecked)).toString() : "false";
17-
if (typeof icon === "object" && "off" in icon && "on" in icon) {
18-
updateFeatureButtonIcon(button, JSON.parse(button.ariaChecked) ? icon.on : icon.off);
19-
} else if (icon instanceof SVGSVGElement) {
20-
updateFeatureButtonIcon(button, icon);
21-
}
22-
listener(JSON.parse(button.ariaChecked) as boolean);
23-
} else {
24-
listener();
15+
if (!isToggle) return listener();
16+
button.ariaChecked = button.ariaChecked ? (!JSON.parse(button.ariaChecked)).toString() : "false";
17+
if (typeof icon === "object" && "off" in icon && "on" in icon) {
18+
updateFeatureButtonIcon(button, JSON.parse(button.ariaChecked) ? icon.on : icon.off);
19+
} else if (icon instanceof SVGSVGElement) {
20+
updateFeatureButtonIcon(button, icon);
2521
}
22+
listener(JSON.parse(button.ariaChecked) as boolean);
2623
}
2724

2825
export function makeFeatureButton<Name extends AllButtonNames, Placement extends ButtonPlacement, Toggle extends boolean>(

src/features/playbackSpeedButtons/index.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { AllButtonNames, YouTubePlayerDiv } from "@/src/types";
1+
import type { YouTubePlayerDiv } from "@/src/types";
22

33
import { addFeatureButton, removeFeatureButton } from "@/src/features/buttonPlacement";
44
import { getFeatureButton, updateFeatureButtonTitle } from "@/src/features/buttonPlacement/utils";
@@ -11,8 +11,8 @@ import { createTooltip, isShortsPage, isWatchPage, waitForSpecificMessage } from
1111
import type { AddButtonFunction, RemoveButtonFunction } from "../index";
1212
let currentPlaybackSpeed = 1;
1313

14-
async function updateTooltip<ButtonName extends AllButtonNames>(
15-
buttonName: ButtonName extends "decreasePlaybackSpeedButton" | "increasePlaybackSpeedButton" ? ButtonName : never,
14+
async function updateTooltip<ButtonName extends "decreasePlaybackSpeedButton" | "increasePlaybackSpeedButton">(
15+
buttonName: ButtonName,
1616
speed: string
1717
) {
1818
const optionsData = await waitForSpecificMessage("options", "request_data", "content");
@@ -39,11 +39,12 @@ async function updateTooltip<ButtonName extends AllButtonNames>(
3939
remove();
4040
updateFeatureButtonTitle(
4141
buttonName,
42-
//@ts-expect-error ↓↓↓
43-
// TODO: Adjust i18n types so it won't cause an error
44-
window.i18nextInstance.t(`pages.content.features.playbackSpeedButtons.buttons.${buttonName}.label`, {
45-
SPEED: speed
46-
})
42+
window.i18nextInstance.t(
43+
`pages.content.features.playbackSpeedButtons.buttons.${buttonName as "decreasePlaybackSpeedButton" | "increasePlaybackSpeedButton"}.label`,
44+
{
45+
SPEED: speed
46+
}
47+
)
4748
);
4849
}
4950

0 commit comments

Comments
 (0)