mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 03:11:46 +00:00
feat: start implementing chromecast API
This commit is contained in:
14
src/electron-chromecast.d.ts
vendored
Normal file
14
src/electron-chromecast.d.ts
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
declare module '@jellybrick/electron-chromecast' {
|
||||
export const chrome: typeof window.chrome;
|
||||
export const requestHandler: (receiverList: Array<object>) => Promise<unknown>;
|
||||
export const castSetting: {
|
||||
devMode: boolean;
|
||||
};
|
||||
export const castConsole: {
|
||||
log: (message: unknown[]) => void;
|
||||
info: (message: unknown[]) => void;
|
||||
warn: (message: unknown[]) => void;
|
||||
error: (message: unknown[]) => void;
|
||||
};
|
||||
export const injectChromeCompatToObject: (obj: object) => void;
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
import { contextBridge, ipcRenderer, IpcRendererEvent, webFrame } from 'electron';
|
||||
import is from 'electron-is';
|
||||
|
||||
import { injectChromeCompatToObject, chrome } from '@jellybrick/electron-chromecast';
|
||||
|
||||
import config from './config';
|
||||
|
||||
import {
|
||||
@ -53,6 +55,8 @@ contextBridge.exposeInMainWorld(
|
||||
'ELECTRON_RENDERER_URL',
|
||||
process.env.ELECTRON_RENDERER_URL,
|
||||
);
|
||||
injectChromeCompatToObject(global);
|
||||
contextBridge.exposeInMainWorld('caster', chrome);
|
||||
|
||||
const [path, script] = ipcRenderer.sendSync('get-renderer-script') as [string | null, string];
|
||||
let blocked = true;
|
||||
|
||||
@ -16,6 +16,8 @@ import { loadI18n, setLanguage, t as i18t } from '@/i18n';
|
||||
import type { PluginConfig } from '@/types/plugins';
|
||||
import type { YoutubePlayer } from '@/types/youtube-player';
|
||||
|
||||
window.chrome.cast = window.caster.cast;
|
||||
|
||||
let api: (Element & YoutubePlayer) | null = null;
|
||||
let isPluginLoaded = false;
|
||||
let isApiLoaded = false;
|
||||
|
||||
1
src/reset.d.ts
vendored
1
src/reset.d.ts
vendored
@ -22,6 +22,7 @@ declare global {
|
||||
ipcRenderer: typeof electronIpcRenderer;
|
||||
mainConfig: typeof config;
|
||||
electronIs: typeof is;
|
||||
caster: typeof window.chrome;
|
||||
ELECTRON_RENDERER_URL: string | undefined;
|
||||
/**
|
||||
* YouTube Music internal variable (Last interaction time)
|
||||
|
||||
@ -35,11 +35,6 @@ img {
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
/* Hide cast button which doesn't work */
|
||||
ytmusic-cast-button {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Remove useless inaccessible button on top-right corner of the video player */
|
||||
.ytp-chrome-top-buttons {
|
||||
display: none !important;
|
||||
|
||||
Reference in New Issue
Block a user