generated from JohnBra/vite-web-extension
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e166355
commit 8ed563f
Showing
22 changed files
with
735 additions
and
6 deletions.
There are no files selected for viewing
Binary file added
BIN
+3.99 KB
...xt screenshots/Playlist Length Settings/Display_Playlist_Length_Information.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.47 KB
... context screenshots/Playlist Length Settings/Method_To_Get_Playlist_Length.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.43 KB
assets/translation context screenshots/Playlist Length Settings/Title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.07 KB
assets/translation context screenshots/YouTube API V3 Key/Api_Key.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+791 Bytes
assets/translation context screenshots/YouTube API V3 Key/getApiKeyLinkText.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import type { Nullable } from "@/src/types"; | ||
import type { ChangeEvent } from "react"; | ||
|
||
import { cn, debounce } from "@/src/utils/utilities"; | ||
import React, { useCallback, useRef, useState } from "react"; | ||
import { IoMdEye, IoMdEyeOff } from "react-icons/io"; | ||
|
||
export type TextInputProps = { | ||
className?: string; | ||
id: string; | ||
input_type: "password" | "text"; | ||
label: string; | ||
onChange: (event: ChangeEvent<HTMLInputElement>) => void; | ||
title: string; | ||
value: string; | ||
}; | ||
|
||
const TextInput: React.FC<TextInputProps> = ({ className, id, input_type, label, onChange, title, value }) => { | ||
const [showPassword, setShowPassword] = useState(false); | ||
const debouncedOnChange = useCallback(debounce(onChange, 300), []); | ||
const inputRef = useRef<Nullable<HTMLInputElement>>(null); | ||
const handleInputWrapperClick = () => { | ||
inputRef.current?.focus(); | ||
}; | ||
// FIXME: cursor not being restored to position it was in when value is saved | ||
return ( | ||
<div aria-valuetext={value} className={cn("relative flex flex-row items-center justify-between gap-4", className)} id={id} title={title}> | ||
<label htmlFor={id}>{label}</label> | ||
<div | ||
className="flex w-40 items-center justify-between rounded-md border border-gray-300 bg-white p-2 text-black dark:multi-['border-gray-700;bg-[#23272a];text-white']" | ||
onClick={handleInputWrapperClick} | ||
> | ||
{input_type === "password" && ( | ||
<button | ||
className="text-black hover:text-black dark:text-white dark:hover:text-white" | ||
onClick={() => setShowPassword(!showPassword)} | ||
type="button" | ||
> | ||
{showPassword ? | ||
<IoMdEye size={18} /> | ||
: <IoMdEyeOff size={18} />} | ||
</button> | ||
)} | ||
<input | ||
className="!m-0 h-fit w-[118px] bg-transparent !p-0 !text-sm focus:outline-none" | ||
id={id} | ||
onChange={({ target: { value } }) => { | ||
debouncedOnChange({ currentTarget: { value } }); | ||
}} | ||
ref={inputRef} | ||
type={showPassword && input_type === "password" ? "text" : input_type} | ||
value={value} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default TextInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import TextInput from "./TextInput"; | ||
|
||
export { TextInput }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import type { Nullable } from "@/src/types"; | ||
|
||
import eventManager from "@/src/utils/EventManager"; | ||
import { YouTube_Enhancer_Public_Youtube_Data_API_V3_Key } from "@/src/utils/constants"; | ||
import { isWatchPage, waitForAllElements, waitForSpecificMessage } from "@/src/utils/utilities"; | ||
|
||
import { headerSelector, initializePlaylistLength, playlistItemsSelector } from "./utils"; | ||
let documentObserver: Nullable<MutationObserver> = null; | ||
export async function enablePlaylistLength() { | ||
const IsWatchPage = isWatchPage(); | ||
const { | ||
data: { | ||
options: { enable_playlist_length, playlist_length_get_method: playlistLengthGetMethod, youtube_data_api_v3_key } | ||
} | ||
} = await waitForSpecificMessage("options", "request_data", "content"); | ||
if (!enable_playlist_length) return; | ||
const urlContainsListParameter = window.location.href.includes("list="); | ||
if (!urlContainsListParameter) return; | ||
await waitForAllElements([headerSelector(), playlistItemsSelector()]); | ||
const apiKey = youtube_data_api_v3_key === "" ? YouTube_Enhancer_Public_Youtube_Data_API_V3_Key : youtube_data_api_v3_key; | ||
const pageType = IsWatchPage ? "watch" : "playlist"; | ||
try { | ||
documentObserver = await initializePlaylistLength({ | ||
apiKey, | ||
pageType, | ||
playlistLengthGetMethod | ||
}); | ||
} catch (error) { | ||
documentObserver?.disconnect(); | ||
documentObserver = null; | ||
documentObserver = await initializePlaylistLength({ | ||
apiKey, | ||
pageType, | ||
playlistLengthGetMethod: "html" | ||
}); | ||
} | ||
} | ||
// FIXME: mix playlist type not falling back to get mode html when get mode is api | ||
export function disablePlaylistLength() { | ||
eventManager.removeEventListeners("playlistLength"); | ||
if (documentObserver) documentObserver.disconnect(); | ||
document.querySelector("#yte-playlist-length-ui")?.remove(); | ||
} |
Oops, something went wrong.