Skip to content

Commit

Permalink
add extra options to disable double click fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
ynshung committed Jan 8, 2024
1 parent f5a33ca commit 4c8a8d3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,8 @@
},
"enable": {
"message": "Enable $1"
},
"fullScreenDoubleClick": {
"message": "Double click to toggle full screen"
}
}
6 changes: 4 additions & 2 deletions src/lib/Events.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { tryToggleFullscreen } from "./HandleFullscreen";
import { PolyDictionary } from "./definitions";
import { getVideo } from "./getters";

/**
* Handle adding event listeners to existing elements.
* For example, adds a double click event to the player to enter fullscreen mode
*/
export function injectEventsToExistingElements() {
export function injectEventsToExistingElements(options: PolyDictionary) {
const player: HTMLElement | null = getVideo();

// double click the player to enter fullscreen mode
if (player !== null) player.addEventListener("dblclick", tryToggleFullscreen);
if (player !== null && options["fullScreenDoubleClick"])
player.addEventListener("dblclick", tryToggleFullscreen);
}
2 changes: 1 addition & 1 deletion src/lib/InjectionSuccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function createNewInjectionState(
populateActionElement(state, settings, features);
}),
new InjectionStateUnit(InjectionItemsEnum.EXISTING_EVENTS, () => {
injectEventsToExistingElements();
injectEventsToExistingElements(options);
}),
new InjectionStateUnit(InjectionItemsEnum.PROGRESS_BAR, () => {
modifyProgressBar(features["progressBar"]);
Expand Down
6 changes: 6 additions & 0 deletions src/lib/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ export const DEFAULT_OPTIONS: PolyDictionary = {
hideShortsOverlay: false,
showVolumeHorizontally: false,
defaultPlaybackRate: 1,
fullScreenDoubleClick: true,
};

export const OPTIONS_ORDER: string[] = [
"defaultPlaybackRate",
"fullScreenDoubleClick",
"seekAmount",
"automaticallyOpenComments",
"skipEnabled",
Expand Down Expand Up @@ -102,6 +104,10 @@ export const OPTION_DICTIONARY: OptionsDictionary = {
min: 0.25,
max: 16,
},
fullScreenDoubleClick: {
desc: local("fullScreenDoubleClick"),
type: "checkbox",
},
};

export function setKeybind(
Expand Down

0 comments on commit 4c8a8d3

Please sign in to comment.