Fix downloader plugin with context isolation

This commit is contained in:
TC
2021-01-12 22:52:21 +01:00
parent 0fafed7c53
commit 79e8fc2fac
2 changed files with 24 additions and 20 deletions

View File

@ -1,3 +1,5 @@
const { contextBridge } = require("electron");
const { ElementFromFile, templatePath, triggerAction } = require("../utils");
const { ACTIONS, CHANNEL } = require("./actions.js");
const { downloadVideoToMP3 } = require("./youtube-dl");
@ -28,7 +30,8 @@ const reinit = () => {
}
};
global.download = () => {
contextBridge.exposeInMainWorld("downloader", {
download: () => {
const videoUrl = window.location.href;
downloadVideoToMP3(
@ -47,7 +50,8 @@ global.download = () => {
reinit,
pluginOptions
);
};
},
});
function observeMenu(options) {
pluginOptions = { ...pluginOptions, ...options };

View File

@ -4,7 +4,7 @@
tabindex="-1"
aria-disabled="false"
aria-selected="false"
onclick="download()"
onclick="downloader.download()"
>
<div
class="menu-icon yt-icon-container yt-icon ytmusic-toggle-menu-service-item-renderer"