mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-15 04:11:47 +00:00
use front load event instead of webcontents.did-finish-load
This commit is contained in:
@ -4,14 +4,6 @@ This is used to determine if plugin is actually active
|
|||||||
*/
|
*/
|
||||||
let enabled = false;
|
let enabled = false;
|
||||||
|
|
||||||
module.exports = (win) => {
|
module.exports = () => enabled = true;
|
||||||
enabled = true;
|
|
||||||
|
|
||||||
win.webContents.on("did-finish-load", () => {
|
module.exports.enabled = () => enabled;
|
||||||
win.webContents.send("did-finish-load");
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports.enabled = () => {
|
|
||||||
return enabled;
|
|
||||||
};
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ module.exports = (options) => {
|
|||||||
setupGlobalShortcuts(options);
|
setupGlobalShortcuts(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcRenderer.on("did-finish-load", () => {
|
window.addEventListener('load', () => {
|
||||||
const noVid = $("#main-panel")?.computedStyleMap().get("display").value === "none";
|
const noVid = $("#main-panel")?.computedStyleMap().get("display").value === "none";
|
||||||
injectVolumeHud(noVid);
|
injectVolumeHud(noVid);
|
||||||
if (!noVid) {
|
if (!noVid) {
|
||||||
@ -156,6 +156,7 @@ function setupVolumeOverride(options) {
|
|||||||
|
|
||||||
video.addEventListener("canplay", () => {
|
video.addEventListener("canplay", () => {
|
||||||
if (typeof options.savedVolume === "number") {
|
if (typeof options.savedVolume === "number") {
|
||||||
|
console.log("canplay video called")
|
||||||
const newVolume = (options.savedVolume / 100).toFixed(2);
|
const newVolume = (options.savedVolume / 100).toFixed(2);
|
||||||
|
|
||||||
video.volume = newVolume;
|
video.volume = newVolume;
|
||||||
|
|||||||
@ -24,10 +24,10 @@ function overrideAddEventListener() {
|
|||||||
|
|
||||||
module.exports = () => {
|
module.exports = () => {
|
||||||
overrideAddEventListener();
|
overrideAddEventListener();
|
||||||
// Restore original function after did-finish-load to avoid keeping Element.prototype altered
|
// Restore original function after finished loading to avoid keeping Element.prototype altered
|
||||||
ipcRenderer.once("did-finish-load", () => { // Called from main to make sure page is completly loaded
|
window.addEventListener('load', () => {
|
||||||
Element.prototype.addEventListener = Element.prototype._addEventListener;
|
Element.prototype.addEventListener = Element.prototype._addEventListener;
|
||||||
Element.prototype._addEventListener = undefined;
|
Element.prototype._addEventListener = undefined;
|
||||||
ignored = undefined;
|
ignored = undefined;
|
||||||
});
|
}, { once: true });
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user