-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from DeepDoge/yewtube-added
[Feature] Yewtube support added
- Loading branch information
Showing
11 changed files
with
180 additions
and
114 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,29 +1,76 @@ | ||
export type PlatformName = 'madiator.com' | 'odysee' | 'app' | ||
export interface ExtensionSettings { | ||
redirect: boolean | ||
targetPlatform: TargetPlatformName | ||
} | ||
|
||
export const DEFAULT_SETTINGS: ExtensionSettings = { redirect: true, targetPlatform: 'odysee' }; | ||
|
||
export function getExtensionSettingsAsync<K extends Array<keyof ExtensionSettings>>(...keys: K): Promise<Pick<ExtensionSettings, K[number]>> { | ||
return new Promise(resolve => chrome.storage.local.get(keys, o => resolve(o as any))); | ||
} | ||
|
||
|
||
export interface PlatformSettings | ||
{ | ||
|
||
export type TargetPlatformName = 'madiator.com' | 'odysee' | 'app' | ||
export interface TargetPlatformSettings { | ||
domainPrefix: string | ||
display: string | ||
displayName: string | ||
theme: string | ||
} | ||
|
||
export const platformSettings: Record<PlatformName, PlatformSettings> = { | ||
'madiator.com': { domainPrefix: 'https://madiator.com/', display: 'Madiator.com', theme: '#075656' }, | ||
odysee: { domainPrefix: 'https://odysee.com/', display: 'Odysee', theme: '#1e013b' }, | ||
app: { domainPrefix: 'lbry://', display: 'App', theme: '#075656' }, | ||
export const TargetPlatformSettings: Record<TargetPlatformName, TargetPlatformSettings> = { | ||
'madiator.com': { | ||
domainPrefix: 'https://madiator.com/', | ||
displayName: 'Madiator.com', | ||
theme: '#075656' | ||
}, | ||
odysee: { | ||
domainPrefix: 'https://odysee.com/', | ||
displayName: 'Odysee', | ||
theme: '#1e013b' | ||
}, | ||
app: { | ||
domainPrefix: 'lbry://', | ||
displayName: 'LBRY App', | ||
theme: '#075656' | ||
}, | ||
}; | ||
|
||
export const getPlatfromSettingsEntiries = () => { | ||
return Object.entries(platformSettings) as any as [Extract<keyof typeof platformSettings, string>, PlatformSettings][] | ||
export const getTargetPlatfromSettingsEntiries = () => { | ||
return Object.entries(TargetPlatformSettings) as any as [Extract<keyof typeof TargetPlatformSettings, string>, TargetPlatformSettings][] | ||
} | ||
|
||
export interface LbrySettings { | ||
enabled: boolean | ||
platform: PlatformName | ||
} | ||
|
||
export const DEFAULT_SETTINGS: LbrySettings = { enabled: true, platform: 'odysee' }; | ||
|
||
export function getSettingsAsync<K extends Array<keyof LbrySettings>>(...keys: K): Promise<Pick<LbrySettings, K[number]>> { | ||
return new Promise(resolve => chrome.storage.local.get(keys, o => resolve(o as any))); | ||
export type SourcePlatfromName = 'youtube.com' | 'yewtu.be' | ||
export interface SourcePlatfromSettings { | ||
hostnames: string[] | ||
htmlQueries: { | ||
mountButtonBefore: string, | ||
videoPlayer: string | ||
} | ||
} | ||
|
||
export const SourcePlatfromSettings: Record<SourcePlatfromName, SourcePlatfromSettings> = { | ||
"yewtu.be": { | ||
hostnames: ['yewtu.be'], | ||
htmlQueries: { | ||
mountButtonBefore: '#watch-on-youtube', | ||
videoPlayer: '#player-container video' | ||
} | ||
}, | ||
"youtube.com": { | ||
hostnames: ['www.youtube.com'], | ||
htmlQueries: { | ||
mountButtonBefore: 'ytd-video-owner-renderer~#subscribe-button', | ||
videoPlayer: '#ytd-player video' | ||
} | ||
} | ||
} | ||
|
||
export function getSourcePlatfromSettingsFromHostname(hostname: string) { | ||
const values = Object.values(SourcePlatfromSettings) | ||
for (const settings of values) | ||
if (settings.hostnames.includes(hostname)) return settings | ||
return null | ||
} |
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 |
---|---|---|
@@ -1,4 +1,13 @@ | ||
.radio-label | ||
font-size: 1.1rem | ||
margin: 15px auto | ||
display: block | ||
|
||
.container | ||
display: grid | ||
grid-auto-flow: row | ||
gap: 1.5em | ||
|
||
.container > section | ||
display: grid | ||
grid-auto-flow: row | ||
gap: 1em |
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
Oops, something went wrong.