mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 10:11:46 +00:00
fix PiP hotkey active in searchbox
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
const { ipcRenderer } = require("electron");
|
||||
|
||||
const { toKeyEvent } = require('keyboardevent-from-electron-accelerator');
|
||||
const keyEventAreEqual = require('keyboardevents-areequal');
|
||||
|
||||
const { getSongMenu } = require("../../providers/dom-elements");
|
||||
const { ElementFromFile, templatePath } = require("../utils");
|
||||
|
||||
@ -74,13 +77,13 @@ const listenForToggle = () => {
|
||||
});
|
||||
}
|
||||
|
||||
function observeMenu(options) {
|
||||
function observeMenu() {
|
||||
document.addEventListener(
|
||||
"apiLoaded",
|
||||
() => {
|
||||
listenForToggle();
|
||||
// remove native listeners
|
||||
cloneButton(".player-minimize-button").onclick = () => {
|
||||
cloneButton(".player-minimize-button").onclick = () => {
|
||||
global.togglePictureInPicture();
|
||||
setTimeout(() => $('#player').click());
|
||||
};
|
||||
@ -97,4 +100,15 @@ function observeMenu(options) {
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = observeMenu;
|
||||
module.exports = (options) => {
|
||||
observeMenu();
|
||||
|
||||
if (options.hotkey) {
|
||||
const hotkeyEvent = toKeyEvent(options.hotkey);
|
||||
window.addEventListener('keydown', (event) => {
|
||||
if (keyEventAreEqual(event, hotkeyEvent) && !$('ytmusic-search-box').opened) {
|
||||
togglePictureInPicture();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user