mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-16 12:42:06 +00:00
Fix downloader plugin with context isolation
This commit is contained in:
@ -1,3 +1,5 @@
|
|||||||
|
const { contextBridge } = require("electron");
|
||||||
|
|
||||||
const { ElementFromFile, templatePath, triggerAction } = require("../utils");
|
const { ElementFromFile, templatePath, triggerAction } = require("../utils");
|
||||||
const { ACTIONS, CHANNEL } = require("./actions.js");
|
const { ACTIONS, CHANNEL } = require("./actions.js");
|
||||||
const { downloadVideoToMP3 } = require("./youtube-dl");
|
const { downloadVideoToMP3 } = require("./youtube-dl");
|
||||||
@ -28,7 +30,8 @@ const reinit = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
global.download = () => {
|
contextBridge.exposeInMainWorld("downloader", {
|
||||||
|
download: () => {
|
||||||
const videoUrl = window.location.href;
|
const videoUrl = window.location.href;
|
||||||
|
|
||||||
downloadVideoToMP3(
|
downloadVideoToMP3(
|
||||||
@ -47,7 +50,8 @@ global.download = () => {
|
|||||||
reinit,
|
reinit,
|
||||||
pluginOptions
|
pluginOptions
|
||||||
);
|
);
|
||||||
};
|
},
|
||||||
|
});
|
||||||
|
|
||||||
function observeMenu(options) {
|
function observeMenu(options) {
|
||||||
pluginOptions = { ...pluginOptions, ...options };
|
pluginOptions = { ...pluginOptions, ...options };
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
aria-disabled="false"
|
aria-disabled="false"
|
||||||
aria-selected="false"
|
aria-selected="false"
|
||||||
onclick="download()"
|
onclick="downloader.download()"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="menu-icon yt-icon-container yt-icon ytmusic-toggle-menu-service-item-renderer"
|
class="menu-icon yt-icon-container yt-icon ytmusic-toggle-menu-service-item-renderer"
|
||||||
|
|||||||
Reference in New Issue
Block a user