Skip to content

Commit

Permalink
Add option to show custom title on hover if casual title is being sho…
Browse files Browse the repository at this point in the history
…wn in casual mode
  • Loading branch information
ajayyy committed Feb 21, 2025
1 parent b492fdb commit d388a30
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion public/_locales
Submodule _locales updated 1 files
+3 −0 en/messages.json
2 changes: 2 additions & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ interface SBConfig {
defaultToCustom: boolean;
alwaysShowShowOriginalButton: boolean;
showOriginalOnHover: boolean;
showCustomOnHoverIfCasual: boolean;
importedConfig: boolean;
replaceTitles: boolean;
replaceThumbnails: boolean;
Expand Down Expand Up @@ -199,6 +200,7 @@ const syncDefaults = {
defaultToCustom: true,
alwaysShowShowOriginalButton: false,
showOriginalOnHover: false,
showCustomOnHoverIfCasual: false,
importedConfig: false,
replaceTitles: true,
replaceThumbnails: true,
Expand Down
31 changes: 31 additions & 0 deletions src/options/CasualChoiceComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ export const CasualChoiceComponent = () => {
const [activeCategories, setActiveCategories] = React.useState(Config.config!.casualModeSettings);
const [showOriginalWhenCasual, setShowOriginalWhenCasual] = React.useState(Config.config!.showOriginalThumbWhenCasual);
const [onlyShowCasualIconForCustom, setOnlyShowCasualIconForCustom] = React.useState(Config.config!.onlyShowCasualIconForCustom);
const [showCustomOnHoverIfCasual, setShowCustomOnHoverIfCasual] = React.useState(Config.config!.showCustomOnHoverIfCasual);
const [showOptionForShowCustomOnHoverIfCasual, setShowOptionForShowCustomOnHoverIfCasual] = React.useState(false);

React.useEffect(() => {
const update = () => {
setShowOptionForShowCustomOnHoverIfCasual(Config.config!.showOriginalOnHover);
}

Config.configSyncListeners.push(update);
update();

return () => {
Config.configSyncListeners = Config.configSyncListeners.filter((l) => l !== update);
}
});

const [openAddCategoryMenu, setOpenAddCategoryMenu] = React.useState(false);

Expand Down Expand Up @@ -136,6 +151,22 @@ export const CasualChoiceComponent = () => {
value={onlyShowCasualIconForCustom}
label={chrome.i18n.getMessage("onlyShowCasualIconForCustom")}
/>

{
showOptionForShowCustomOnHoverIfCasual &&
<ToggleOptionComponent
id="showCustomOnHoverIfCasual"
style={{
paddingTop: "15px"
}}
onChange={(value) => {
setShowCustomOnHoverIfCasual(value);
Config.config!.showCustomOnHoverIfCasual = value;
}}
value={showCustomOnHoverIfCasual}
label={chrome.i18n.getMessage("showCustomOnHoverIfCasual")}
/>
}
</div>
</div>
</div>
Expand Down
7 changes: 5 additions & 2 deletions src/videoBranding/videoBranding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,13 @@ function getAndUpdateVideoBrandingInstances(videoID: VideoID, updateBranding: ()

export async function setShowCustomBasedOnDefault(videoID: VideoID, originalTitleElement: HTMLElement, brandingLocation: BrandingLocation, value: boolean): Promise<void> {
if (videoBrandingInstances[videoID]) {
const showThreeStages = await showThreeShowOriginalStages(videoID, originalTitleElement, brandingLocation);
const alwaysShowCustom = showThreeStages && Config.config!.showOriginalOnHover && Config.config!.showCustomOnHoverIfCasual;

// If value true, use default, otherwise use opposite of default
return await internalSetShowCustom(videoID, originalTitleElement, brandingLocation,
!!videoBrandingInstances[videoID].showCustomBranding.originalValue === value,
(await showThreeShowOriginalStages(videoID, originalTitleElement, brandingLocation)) ? value : undefined);
alwaysShowCustom || (!!videoBrandingInstances[videoID].showCustomBranding.originalValue === value),
showThreeStages ? value : undefined);
}
}

Expand Down

0 comments on commit d388a30

Please sign in to comment.