Compare commits

...

36 Commits

Author SHA1 Message Date
6ab01056e0 Merge pull request #79 from th-ch/advanced-config
Refactor config, custom plugin options
2020-12-03 21:48:57 +01:00
TC
4dcbd2e7f0 Add plugin options in migration 2020-12-03 20:43:04 +01:00
TC
b94d0d4e8b Adblocker - advanced options (caching or not, additional lists) 2020-12-03 20:43:04 +01:00
TC
7b20b9339d Download plugin - advanced options (folder, FFmpeg args) 2020-12-03 20:43:04 +01:00
TC
4d4a1f038b Custom plugin options 2020-12-03 20:42:58 +01:00
TC
e5ec79e345 Watch changes in config and update menu 2020-12-03 18:31:01 +01:00
TC
f4fe5c2a58 Allow editing config (advanced) 2020-12-03 18:25:31 +01:00
TC
a5130c1d3f Move migrations into separate const 2020-12-03 18:25:08 +01:00
TC
8ab2da0482 Refactor config for simpler use and advanced options in plugins 2020-12-03 18:16:37 +01:00
TC
1b54b19f3f Add "build:linux" script 2020-12-02 22:22:05 +01:00
TC
be7e6e431f Bump version to 1.6.5 2020-12-02 22:14:43 +01:00
6e42b097f8 Merge pull request #77 from th-ch/disable-hardware-acceleration
Add option to disable hardware acceleration
2020-12-02 22:12:42 +01:00
TC
ef9cd8cd24 Add option to disable hardware acceleration 2020-12-02 22:07:15 +01:00
8f3e165917 Merge pull request #76 from th-ch/downloader-plugin-retry-and-upgrade-dep
Downloader plugin - retry and upgrade dependencies
2020-12-02 21:41:04 +01:00
TC
33a11efe9a Update ytdl-core to 4.1.1 2020-12-02 21:16:39 +01:00
TC
9a97436cd8 Allow up to 3 retries in downloader 2020-12-02 21:16:12 +01:00
f7935c0024 Merge pull request #70 from hbarsaiyan/master
Reflect Arch Linux package name change
2020-11-29 21:17:02 +01:00
2b33d4e857 Reflect Arch Linux package name change
Package name has been changed to youtube-music-bin.
2020-11-29 23:57:07 +05:30
ed16c35a57 Merge pull request #67 from th-ch/hide-menu
Option to hide menu
2020-11-28 18:45:53 +01:00
TC
ae5b85d8d7 Autoupdate modal: add download/disable updates buttons 2020-11-28 18:13:41 +01:00
47b4414eb3 Merge pull request #68 from hbarsaiyan/master
Add Arch Linux installation instructions
2020-11-28 11:09:07 +01:00
e329bb2201 Add Arch Linux installation instructions 2020-11-28 15:22:34 +05:30
TC
155ef9e5f5 Bump version 2020-11-27 21:39:33 +01:00
TC
4bac3ace18 Option to hide menu (win/linux) 2020-11-27 21:39:15 +01:00
1d2b53f6ee Merge pull request #64 from th-ch/ci
Improve CI
2020-11-24 00:32:07 +01:00
TC
0fd49330d3 CI: cache yarn directory 2020-11-24 00:13:01 +01:00
TC
4b0e79345f Fail fast (Can only re-run all jobs, not just one) 2020-11-24 00:13:01 +01:00
0c819e9aa9 Merge pull request #63 from th-ch/menu-visible
Ensure menu is visible on all platforms
2020-11-23 23:41:07 +01:00
20d591c554 Merge pull request #62 from th-ch/snyk-upgrade-407335ffa685010c89f68cbb1a8b27a6
[Snyk] Upgrade @cliqz/adblocker-electron from 1.18.3 to 1.18.4
2020-11-23 23:29:04 +01:00
TC
002469a98d Bump adblocker 2020-11-23 23:16:54 +01:00
TC
3bc8430201 No CI run on pull_request (already on every push) 2020-11-23 23:11:44 +01:00
TC
db447a5d62 Bump patch version 2020-11-23 23:04:16 +01:00
TC
72527d0522 Disable autoHideMenuBar (so menu bar is always visible) 2020-11-23 22:59:48 +01:00
TC
cf4827d780 Run CI on every push/PR 2020-11-23 22:55:20 +01:00
TC
9b02591767 Test that menu bar is visible 2020-11-23 22:52:00 +01:00
2b243f6dcb fix: upgrade @cliqz/adblocker-electron from 1.18.3 to 1.18.4
Snyk has created this PR to upgrade @cliqz/adblocker-electron from 1.18.3 to 1.18.4.

See this package in npm:


See this project in Snyk:
https://app.snyk.io/org/th-ch/project/81809c53-bb7b-46b9-a0d7-806d45d74ac6?utm_source=github&utm_medium=upgrade-pr
2020-11-23 02:19:19 +00:00
19 changed files with 389 additions and 211 deletions

View File

@ -1,19 +1,14 @@
name: Build YouTube Music
on:
push:
branches:
- master
pull_request:
branches:
- master
- push
jobs:
build:
name: Build YouTube Music
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
fail-fast: true
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
@ -25,6 +20,18 @@ jobs:
with:
node-version: "12.x"
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn --frozen-lockfile

37
config/defaults.js Normal file
View File

@ -0,0 +1,37 @@
const defaultConfig = {
"window-size": {
width: 1100,
height: 550,
},
url: "https://music.youtube.com",
options: {
tray: false,
appVisible: true,
autoUpdates: true,
hideMenu: false,
startAtLogin: false,
disableHardwareAcceleration: false,
},
plugins: {
// Enabled plugins
navigation: {
enabled: true,
},
shortcuts: {
enabled: true,
},
adblocker: {
enabled: true,
cache: true,
additionalBlockLists: [], // Additional list of filters, e.g "https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/filters.txt"
},
// Disabled plugins
downloader: {
enabled: false,
ffmpegArgs: [], // e.g. ["-b:a", "192k"] for an audio bitrate of 192kb/s
downloadFolder: undefined, // Custom download folder (absolute path)
},
},
};
module.exports = defaultConfig;

18
config/index.js Normal file
View File

@ -0,0 +1,18 @@
const plugins = require("./plugins");
const store = require("./store");
const set = (key, value) => {
store.set(key, value);
};
const get = (key) => {
return store.get(key);
};
module.exports = {
get,
set,
edit: () => store.openInEditor(),
watch: (cb) => store.onDidAnyChange(cb),
plugins,
};

41
config/plugins.js Normal file
View File

@ -0,0 +1,41 @@
const store = require("./store");
function getEnabled() {
const plugins = store.get("plugins");
const enabledPlugins = Object.entries(plugins).filter(([plugin, options]) =>
isEnabled(plugin)
);
return enabledPlugins;
}
function isEnabled(plugin) {
const pluginConfig = store.get("plugins")[plugin];
return pluginConfig !== undefined && pluginConfig.enabled;
}
function setOptions(plugin, options) {
const plugins = store.get("plugins");
store.set("plugins", {
...plugins,
[plugin]: {
...plugins[plugin],
...options,
},
});
}
function enable(plugin) {
setOptions(plugin, { enabled: true });
}
function disable(plugin) {
setOptions(plugin, { enabled: false });
}
module.exports = {
isEnabled,
getEnabled,
enable,
disable,
setOptions,
};

40
config/store.js Normal file
View File

@ -0,0 +1,40 @@
const Store = require("electron-store");
const defaults = require("./defaults");
const migrations = {
">=1.7.0": (store) => {
const enabledPlugins = store.get("plugins");
if (!Array.isArray(enabledPlugins)) {
console.warn("Plugins are not in array format, cannot migrate");
return;
}
// Include custom options
const plugins = {
adblocker: {
enabled: true,
cache: true,
additionalBlockLists: [],
},
downloader: {
enabled: false,
ffmpegArgs: [], // e.g. ["-b:a", "192k"] for an audio bitrate of 192kb/s
downloadFolder: undefined, // Custom download folder (absolute path)
},
};
enabledPlugins.forEach((enabledPlugin) => {
plugins[enabledPlugin] = {
...plugins[enabledPlugin],
enabled: true,
};
});
store.set("plugins", plugins);
},
};
module.exports = new Store({
defaults,
clearInvalidConfig: false,
migrations,
});

View File

@ -5,15 +5,8 @@ const electron = require("electron");
const is = require("electron-is");
const { autoUpdater } = require("electron-updater");
const config = require("./config");
const { setApplicationMenu } = require("./menu");
const {
autoUpdate,
getEnabledPlugins,
isAppVisible,
isTrayEnabled,
store,
startAtLogin,
} = require("./store");
const { fileExists, injectCSS } = require("./plugins/utils");
const { isTesting } = require("./utils/testing");
const { setUpTray } = require("./tray");
@ -25,6 +18,12 @@ app.commandLine.appendSwitch(
"--experimental-wasm-threads --experimental-wasm-bulk-memory"
);
app.allowRendererProcessReuse = true; // https://github.com/electron/electron/issues/18397
if (config.get("options.disableHardwareAcceleration")) {
if (is.dev()) {
console.log("Disabling hardware acceleration");
}
app.disableHardwareAcceleration();
}
// Adds debug features like hotkeys for triggering dev tools and reload
require("electron-debug")();
@ -55,19 +54,19 @@ function loadPlugins(win) {
}
});
getEnabledPlugins().forEach((plugin) => {
config.plugins.getEnabled().forEach(([plugin, options]) => {
console.log("Loaded plugin - " + plugin);
const pluginPath = path.join(__dirname, "plugins", plugin, "back.js");
fileExists(pluginPath, () => {
const handle = require(pluginPath);
handle(win);
handle(win, options);
});
});
}
function createMainWindow() {
const windowSize = store.get("window-size");
const windowMaximized = store.get("window-maximized");
const windowSize = config.get("window-size");
const windowMaximized = config.get("window-maximized");
const win = new electron.BrowserWindow({
icon: icon,
@ -85,31 +84,34 @@ function createMainWindow() {
},
frame: !is.macOS(),
titleBarStyle: is.macOS() ? "hiddenInset" : "default",
autoHideMenuBar: true,
autoHideMenuBar: config.get("options.hideMenu"),
});
if (windowMaximized) {
win.maximize();
}
win.webContents.loadURL(store.get("url"));
win.webContents.loadURL(config.get("url"));
win.on("closed", onClosed);
win.on("move", () => {
let position = win.getPosition();
store.set("window-position", { x: position[0], y: position[1] });
config.set("window-position", { x: position[0], y: position[1] });
});
win.on("resize", () => {
const windowSize = win.getSize();
store.set("window-maximized", win.isMaximized());
config.set("window-maximized", win.isMaximized());
if (!win.isMaximized()) {
store.set("window-size", { width: windowSize[0], height: windowSize[1] });
config.set("window-size", {
width: windowSize[0],
height: windowSize[1],
});
}
});
win.once("ready-to-show", () => {
if (isAppVisible()) {
if (config.get("options.appVisible")) {
win.show();
}
});
@ -134,7 +136,7 @@ app.on("browser-window-created", (event, win) => {
win.webContents.on("did-navigate-in-page", () => {
const url = win.webContents.getURL();
if (url.startsWith("https://music.youtube.com")) {
store.set("url", url);
config.set("url", url);
}
});
@ -187,31 +189,48 @@ app.on("activate", () => {
app.on("ready", () => {
mainWindow = createMainWindow();
setApplicationMenu(mainWindow);
config.watch(() => {
setApplicationMenu(mainWindow);
});
setUpTray(app, mainWindow);
// Autostart at login
app.setLoginItemSettings({
openAtLogin: startAtLogin(),
openAtLogin: config.get("options.startAtLogin"),
});
if (!is.dev() && autoUpdate()) {
if (!is.dev() && config.get("options.autoUpdates")) {
autoUpdater.checkForUpdatesAndNotify();
autoUpdater.on("update-available", () => {
const downloadLink =
"https://github.com/th-ch/youtube-music/releases/latest";
const dialogOpts = {
type: "info",
buttons: ["OK"],
buttons: ["OK", "Download", "Disable updates"],
title: "Application Update",
message: "A new version is available",
detail:
"A new version is available and can be downloaded at https://github.com/th-ch/youtube-music/releases/latest",
detail: `A new version is available and can be downloaded at ${downloadLink}`,
};
electron.dialog.showMessageBox(dialogOpts);
electron.dialog.showMessageBox(dialogOpts).then((dialogOutput) => {
switch (dialogOutput.response) {
// Download
case 1:
electron.shell.openExternal(downloadLink);
break;
// Disable updates
case 2:
config.set("options.autoUpdates", false);
break;
default:
break;
}
});
});
}
// Optimized for Mac OS X
if (is.macOS()) {
if (!isAppVisible()) {
if (!config.get("options.appVisible")) {
app.dock.hide();
}
}
@ -221,7 +240,7 @@ app.on("ready", () => {
forceQuit = true;
});
if (is.macOS() || isTrayEnabled()) {
if (is.macOS() || config.get("options.tray")) {
mainWindow.on("close", (event) => {
// Hide the window instead of quitting (quit is available in tray options)
if (!forceQuit) {

104
menu.js
View File

@ -2,34 +2,34 @@ const { app, Menu } = require("electron");
const is = require("electron-is");
const { getAllPlugins } = require("./plugins/utils");
const {
isPluginEnabled,
enablePlugin,
disablePlugin,
autoUpdate,
isAppVisible,
isTrayEnabled,
setOptions,
startAtLogin,
} = require("./store");
const config = require("./config");
const mainMenuTemplate = (win) => [
{
label: "Plugins",
submenu: getAllPlugins().map((plugin) => {
return {
label: plugin,
type: "checkbox",
checked: isPluginEnabled(plugin),
click: (item) => {
if (item.checked) {
enablePlugin(plugin);
} else {
disablePlugin(plugin);
}
submenu: [
...getAllPlugins().map((plugin) => {
return {
label: plugin,
type: "checkbox",
checked: config.plugins.isEnabled(plugin),
click: (item) => {
if (item.checked) {
config.plugins.enable(plugin);
} else {
config.plugins.disable(plugin);
}
},
};
}),
{ type: "separator" },
{
label: "Advanced options",
click: () => {
config.edit();
},
};
}),
},
],
},
{
label: "Options",
@ -37,11 +37,31 @@ const mainMenuTemplate = (win) => [
{
label: "Auto-update",
type: "checkbox",
checked: autoUpdate(),
checked: config.get("options.autoUpdates"),
click: (item) => {
setOptions({ autoUpdates: item.checked });
config.set("options.autoUpdates", item.checked);
},
},
{
label: "Disable hardware acceleration",
type: "checkbox",
checked: config.get("options.disableHardwareAcceleration"),
click: (item) => {
config.set("options.disableHardwareAcceleration", item.checked);
},
},
...(is.windows() || is.linux()
? [
{
label: "Hide menu",
type: "checkbox",
checked: config.get("options.hideMenu"),
click: (item) => {
config.set("options.hideMenu", item.checked);
},
},
]
: []),
...(is.windows() || is.macOS()
? // Only works on Win/Mac
// https://www.electronjs.org/docs/api/app#appsetloginitemsettingssettings-macos-windows
@ -49,9 +69,9 @@ const mainMenuTemplate = (win) => [
{
label: "Start at login",
type: "checkbox",
checked: startAtLogin(),
checked: config.get("options.startAtLogin"),
click: (item) => {
setOptions({ startAtLogin: item.checked });
config.set("options.startAtLogin", item.checked);
},
},
]
@ -62,23 +82,35 @@ const mainMenuTemplate = (win) => [
{
label: "Disabled",
type: "radio",
checked: !isTrayEnabled(),
click: () => setOptions({ tray: false, appVisible: true }),
checked: !config.get("options.tray"),
click: () => {
config.set("options.tray", false);
config.set("options.appVisible", true);
},
},
{
label: "Enabled + app visible",
type: "radio",
checked: isTrayEnabled() && isAppVisible(),
click: () => setOptions({ tray: true, appVisible: true }),
checked:
config.get("options.tray") && config.get("options.appVisible"),
click: () => {
config.set("options.tray", true);
config.set("options.appVisible", true);
},
},
{
label: "Enabled + app hidden",
type: "radio",
checked: isTrayEnabled() && !isAppVisible(),
click: () => setOptions({ tray: true, appVisible: false }),
checked:
config.get("options.tray") && !config.get("options.appVisible"),
click: () => {
config.set("options.tray", true);
config.set("options.appVisible", false);
},
},
],
},
{ type: "separator" },
{
label: "Toggle DevTools",
// Cannot use "toggleDevTools" role in MacOS
@ -92,6 +124,12 @@ const mainMenuTemplate = (win) => [
}
},
},
{
label: "Advanced options",
click: () => {
config.edit();
},
},
],
},
];

View File

@ -1,7 +1,7 @@
{
"name": "youtube-music",
"productName": "YouTube Music",
"version": "1.6.2",
"version": "1.7.0",
"description": "YouTube Music Desktop App - including custom plugins",
"license": "MIT",
"repository": "th-ch/youtube-music",
@ -33,6 +33,7 @@
"postinstall": "yarn run icon && yarn run plugins",
"clean": "rimraf dist",
"build": "yarn run clean && electron-builder --win --mac --linux",
"build:linux": "yarn run clean && electron-builder --linux",
"build:mac": "yarn run clean && electron-builder --mac",
"build:win": "yarn run clean && electron-builder --win",
"plugins": "yarn run plugin:adblocker && yarn run plugin:autoconfirm",
@ -47,7 +48,7 @@
"npm": "Please use yarn and not npm"
},
"dependencies": {
"@cliqz/adblocker-electron": "^1.18.3",
"@cliqz/adblocker-electron": "^1.18.6",
"@ffmpeg/core": "^0.8.4",
"@ffmpeg/ffmpeg": "^0.9.5",
"YoutubeNonStop": "git://github.com/lawfx/YoutubeNonStop.git#v0.8.0",
@ -59,7 +60,7 @@
"electron-updater": "^4.3.5",
"filenamify": "^4.2.0",
"node-fetch": "^2.6.1",
"ytdl-core": "^4.0.3"
"ytdl-core": "^4.1.1"
},
"devDependencies": {
"electron": "^10.1.3",

View File

@ -1,2 +1,7 @@
const { loadAdBlockerEngine } = require("./blocker");
module.exports = (win) => loadAdBlockerEngine(win.webContents.session);
module.exports = (win, options) =>
loadAdBlockerEngine(
win.webContents.session,
options.cache,
options.additionalBlockLists
);

View File

@ -1,4 +1,4 @@
const { promises } = require("fs"); // used for caching
const { existsSync, promises, unlinkSync } = require("fs"); // used for caching
const path = require("path");
const { ElectronBlocker } = require("@cliqz/adblocker-electron");
@ -8,16 +8,28 @@ const SOURCES = [
"https://raw.githubusercontent.com/kbinani/adblock-youtube-ads/master/signed.txt",
];
const loadAdBlockerEngine = (session = undefined) =>
const loadAdBlockerEngine = (
session = undefined,
cache = true,
additionalBlockLists = []
) => {
const adBlockerCache = path.resolve(__dirname, "ad-blocker-engine.bin");
if (!cache && existsSync(adBlockerCache)) {
unlinkSync(adBlockerCache);
}
const cachingOptions = cache
? {
path: adBlockerCache,
read: promises.readFile,
write: promises.writeFile,
}
: undefined;
ElectronBlocker.fromLists(
fetch,
SOURCES,
[...SOURCES, ...additionalBlockLists],
{},
{
path: path.resolve(__dirname, "ad-blocker-engine.bin"),
read: promises.readFile,
write: promises.writeFile,
}
cachingOptions
)
.then((blocker) => {
if (session) {
@ -27,6 +39,7 @@ const loadAdBlockerEngine = (session = undefined) =>
}
})
.catch((err) => console.log("Error loading adBlocker engine", err));
};
module.exports = { loadAdBlockerEngine };
if (require.main === module) {

View File

@ -7,6 +7,7 @@ let progress = null;
const downloadButton = ElementFromFile(
templatePath(__dirname, "download.html")
);
let pluginOptions = {};
const observer = new MutationObserver((mutations, observer) => {
if (!menu) {
@ -43,11 +44,13 @@ global.download = () => {
triggerAction(CHANNEL, ACTIONS.ERROR, error);
reinit();
},
reinit
reinit,
pluginOptions
);
};
function observeMenu() {
function observeMenu(options) {
pluginOptions = { ...pluginOptions, ...options };
observer.observe(document, {
childList: true,
subtree: true,

View File

@ -19,7 +19,13 @@ const ffmpeg = createFFmpeg({
progress: () => {}, // console.log,
});
const downloadVideoToMP3 = (videoUrl, sendFeedback, sendError, reinit) => {
const downloadVideoToMP3 = (
videoUrl,
sendFeedback,
sendError,
reinit,
options
) => {
sendFeedback("Downloading…");
let videoName = "YouTube Music - Unknown title";
@ -29,6 +35,7 @@ const downloadVideoToMP3 = (videoUrl, sendFeedback, sendError, reinit) => {
filter: "audioonly",
quality: "highestaudio",
highWaterMark: 32 * 1024 * 1024, // 32 MB
requestOptions: { maxRetries: 3 },
});
} catch (err) {
sendError(err);
@ -53,11 +60,18 @@ const downloadVideoToMP3 = (videoUrl, sendFeedback, sendError, reinit) => {
.on("error", sendError)
.on("end", () => {
const buffer = Buffer.concat(chunks);
toMP3(videoName, buffer, sendFeedback, sendError, reinit);
toMP3(videoName, buffer, sendFeedback, sendError, reinit, options);
});
};
const toMP3 = async (videoName, buffer, sendFeedback, sendError, reinit) => {
const toMP3 = async (
videoName,
buffer,
sendFeedback,
sendError,
reinit,
options
) => {
const safeVideoName = randomBytes(32).toString("hex");
try {
@ -70,11 +84,17 @@ const toMP3 = async (videoName, buffer, sendFeedback, sendError, reinit) => {
ffmpeg.FS("writeFile", safeVideoName, buffer);
sendFeedback("Converting…");
await ffmpeg.run("-i", safeVideoName, safeVideoName + ".mp3");
await ffmpeg.run(
"-i",
safeVideoName,
...options.ffmpegArgs,
safeVideoName + ".mp3"
);
const folder = options.downloadFolder || downloadsFolder();
const filename = filenamify(videoName + ".mp3", { replacement: "_" });
writeFileSync(
join(downloadsFolder(), filename),
join(folder, filename),
ffmpeg.FS("readFile", safeVideoName + ".mp3")
);

View File

@ -2,31 +2,31 @@ const path = require("path");
const { remote } = require("electron");
const { getEnabledPlugins, store } = require("./store");
const { fileExists } = require("./plugins/utils");
const config = require("./config");
const { fileExists } = require("./plugins/utils");
const plugins = getEnabledPlugins();
const plugins = config.plugins.getEnabled();
plugins.forEach(plugin => {
plugins.forEach(([plugin, options]) => {
const pluginPath = path.join(__dirname, "plugins", plugin, "actions.js");
fileExists(pluginPath, () => {
const actions = require(pluginPath).global || {};
Object.keys(actions).forEach(actionName => {
Object.keys(actions).forEach((actionName) => {
global[actionName] = actions[actionName];
});
});
});
document.addEventListener("DOMContentLoaded", () => {
plugins.forEach(plugin => {
plugins.forEach(([plugin, options]) => {
const pluginPath = path.join(__dirname, "plugins", plugin, "front.js");
fileExists(pluginPath, () => {
const run = require(pluginPath);
run();
run(options);
});
});
// Add action for reloading
global.reload = () =>
remote.getCurrentWindow().webContents.loadURL(store.get("url"));
remote.getCurrentWindow().webContents.loadURL(config.get("url"));
});

View File

@ -18,6 +18,10 @@
You can check out the [latest release](https://github.com/th-ch/youtube-music/releases/latest) to quickly find the latest version.
**Arch Linux**
Install the `youtube-music-bin` package from the AUR. For AUR installation instructions, take a look at this [wiki page](https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_packages).
## Available plugins:
- **Ad Blocker**: block all ads and tracking out of the box

View File

@ -1,35 +0,0 @@
const Store = require("electron-store");
const plugins = require("./plugins");
const store = new Store({
defaults: {
"window-size": {
width: 1100,
height: 550,
},
url: "https://music.youtube.com",
plugins: ["navigation", "shortcuts", "adblocker"],
options: {
tray: false,
appVisible: true,
autoUpdates: true,
startAtLogin: false,
},
},
});
module.exports = {
store: store,
// Plugins
isPluginEnabled: plugin => plugins.isEnabled(store, plugin),
getEnabledPlugins: () => plugins.getEnabledPlugins(store),
enablePlugin: plugin => plugins.enablePlugin(store, plugin),
disablePlugin: plugin => plugins.disablePlugin(store, plugin),
// Options
setOptions: options =>
store.set("options", { ...store.get("options"), ...options }),
isTrayEnabled: () => store.get("options.tray"),
isAppVisible: () => store.get("options.appVisible"),
autoUpdate: () => store.get("options.autoUpdates"),
startAtLogin: () => store.get("options.startAtLogin"),
};

View File

@ -1,31 +0,0 @@
function getEnabledPlugins(store) {
return store.get("plugins");
}
function isEnabled(store, plugin) {
return store.get("plugins").indexOf(plugin) > -1;
}
function enablePlugin(store, plugin) {
let plugins = getEnabledPlugins(store);
if (plugins.indexOf(plugin) === -1) {
plugins.push(plugin);
store.set("plugins", plugins);
}
}
function disablePlugin(store, plugin) {
let plugins = getEnabledPlugins(store);
let index = plugins.indexOf(plugin);
if (index > -1) {
plugins.splice(index, 1);
store.set("plugins", plugins);
}
}
module.exports = {
isEnabled : isEnabled,
getEnabledPlugins: getEnabledPlugins,
enablePlugin : enablePlugin,
disablePlugin : disablePlugin
};

View File

@ -6,6 +6,9 @@ describe("YouTube Music App", () => {
const win = app.browserWindow;
const isMenuVisible = await win.isMenuBarVisible();
expect(isMenuVisible).toBe(true);
const isVisible = await win.isVisible();
expect(isVisible).toBe(true);

View File

@ -2,15 +2,15 @@ const path = require("path");
const { Menu, nativeImage, Tray } = require("electron");
const config = require("./config");
const { mainMenuTemplate } = require("./menu");
const { isTrayEnabled } = require("./store");
const { clickInYoutubeMusic } = require("./utils/youtube-music");
// Prevent tray being garbage collected
let tray;
module.exports.setUpTray = (app, win) => {
if (!isTrayEnabled()) {
if (!config.get("options.tray")) {
tray = undefined;
return;
}

View File

@ -372,37 +372,37 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@cliqz/adblocker-content@^1.18.3":
version "1.18.3"
resolved "https://registry.yarnpkg.com/@cliqz/adblocker-content/-/adblocker-content-1.18.3.tgz#c9511f9857614303d61d5f4c37f2979cfa6f3865"
integrity sha512-mCLlGg4B8P2VWtJpSAJStR9HeRNt5Jo4D0MIOdXIkdSFjCWcXUSwqlUtu5GBvA8iFp9cGgHC/EYeyUW1SbuvYg==
"@cliqz/adblocker-content@^1.18.6":
version "1.18.6"
resolved "https://registry.yarnpkg.com/@cliqz/adblocker-content/-/adblocker-content-1.18.6.tgz#a65dd518f3e6d1f2e9fee36ca5ae5615ba7b4cfd"
integrity sha512-OXrca20n+cMn9Ase+6oeX3fTmkauQMSb//lMLs56pHyra4foxN5o1rNiBG7qNIypdGQBFiTtGG7Vbp7YO5RQMw==
"@cliqz/adblocker-electron-preload@^1.18.3":
version "1.18.3"
resolved "https://registry.yarnpkg.com/@cliqz/adblocker-electron-preload/-/adblocker-electron-preload-1.18.3.tgz#7e8c6651adea72202eb380b834d936c4486f4df0"
integrity sha512-MBfcFXpkZ08sTU1gQIVETmfpKODkc3ymg3cOpgf8RaeP0gX0RVW/trAA5LJINuOYUWXc2diNOn/GJ0W1oUjXbw==
"@cliqz/adblocker-electron-preload@^1.18.6":
version "1.18.6"
resolved "https://registry.yarnpkg.com/@cliqz/adblocker-electron-preload/-/adblocker-electron-preload-1.18.6.tgz#57ec2dac09bbacb03b143609345638e98132f985"
integrity sha512-cOK6ZuN3j0qLCZUj8oCf2PmPY837VTxtZM6bZl1x5xWLy/31x7186Wk0DP3C9MXU7gUhlqYxxKpbJDLZgFJ7Qw==
dependencies:
"@cliqz/adblocker-content" "^1.18.3"
"@cliqz/adblocker-content" "^1.18.6"
"@cliqz/adblocker-electron@^1.18.3":
version "1.18.3"
resolved "https://registry.yarnpkg.com/@cliqz/adblocker-electron/-/adblocker-electron-1.18.3.tgz#01a9fd6793afaf62ff9570f25350d33958ae7ae7"
integrity sha512-HIeg8QH4+uBxeU7CH//Yxil9DnDPxthpJNzhm0YN+I7E+PDVlxSqHcQz9Lc/5RguskO5l+PCGH+Iw8eNKPOLAg==
"@cliqz/adblocker-electron@^1.18.6":
version "1.18.6"
resolved "https://registry.yarnpkg.com/@cliqz/adblocker-electron/-/adblocker-electron-1.18.6.tgz#e387a1dc6f3f4a4005d299b37723899be4f0967b"
integrity sha512-RGy003FHsvcLoGYaQIJVNWX8ZUQmK+Dbo0LeQAcsP96vOaTHHFOVj0Auhwkg7mZASiR9/XnoNepKIifO2zQVfw==
dependencies:
"@cliqz/adblocker" "^1.18.3"
"@cliqz/adblocker-electron-preload" "^1.18.3"
"@cliqz/adblocker" "^1.18.6"
"@cliqz/adblocker-electron-preload" "^1.18.6"
tldts-experimental "^5.6.21"
"@cliqz/adblocker@^1.18.3":
version "1.18.3"
resolved "https://registry.yarnpkg.com/@cliqz/adblocker/-/adblocker-1.18.3.tgz#a1a2022f6a8d093d1c31167d4bdb5a03e0b57002"
integrity sha512-fkGky+ffAsXw9WIS+cV9zm8EMzdjRKU/uO196yCFHYICByZyREBie3lMNNKQ6RVSUeEVFOx1JlEKkY9Bze/9xQ==
"@cliqz/adblocker@^1.18.6":
version "1.18.6"
resolved "https://registry.yarnpkg.com/@cliqz/adblocker/-/adblocker-1.18.6.tgz#07d075c45017db7cd2aff19afe466ad53217d318"
integrity sha512-+ro8DoqBaMt9nmfjJF+0Om03/9hdDhRx6NJKzwmW7Pfvd/XhqJ+NiDtdusABSERhCE3nUXCWdu5j09X9HiX6Vg==
dependencies:
"@remusao/guess-url-type" "^1.1.2"
"@remusao/small" "^1.1.2"
"@remusao/smaz" "^1.7.1"
"@types/chrome" "^0.0.123"
"@types/firefox-webext-browser" "^78.0.0"
"@types/chrome" "^0.0.126"
"@types/firefox-webext-browser" "^82.0.0"
tldts-experimental "^5.6.21"
"@cnakazawa/watch@^1.0.3":
@ -1100,10 +1100,10 @@
"@types/node" "*"
"@types/responselike" "*"
"@types/chrome@^0.0.123":
version "0.0.123"
resolved "https://registry.yarnpkg.com/@types/chrome/-/chrome-0.0.123.tgz#3bd094ae3b3920e8210ca63e6b5927358fafc1a5"
integrity sha512-fG6GPreuSY+Z+0e3dtBz5MJ5qyZ2feOZISG8udxBiuwUYqykK1q4NxkjfzL2F5I05LqK2ojP7ZR08Gcfo3ubHQ==
"@types/chrome@^0.0.126":
version "0.0.126"
resolved "https://registry.yarnpkg.com/@types/chrome/-/chrome-0.0.126.tgz#f9f3436712f0c7c12ea9798abc9b95575ad7b23a"
integrity sha512-191z7uoyfbGU+z7/m45j9XbWugWqVHVPMM4hJV5cZ+3YzGCT9wFjMUHO3Wr3Xvo8aVodvRNu28u7lvEaAnfbzg==
dependencies:
"@types/filesystem" "*"
"@types/har-format" "*"
@ -1140,10 +1140,10 @@
resolved "https://registry.yarnpkg.com/@types/filewriter/-/filewriter-0.0.28.tgz#c054e8af4d9dd75db4e63abc76f885168714d4b3"
integrity sha1-wFTor02d11205jq8dviFFocU1LM=
"@types/firefox-webext-browser@^78.0.0":
version "78.0.1"
resolved "https://registry.yarnpkg.com/@types/firefox-webext-browser/-/firefox-webext-browser-78.0.1.tgz#9c3b929c65a8263facac03ab930b0fb0f8addfbb"
integrity sha512-0d7oiI9K6Y4efP4Crl3JB88zYl7vaRdLtumqz8v6axMF8RCnK0NaGUjL4DnyQ7GLPo98b+s0BSRalaxAXgvPAQ==
"@types/firefox-webext-browser@^82.0.0":
version "82.0.0"
resolved "https://registry.yarnpkg.com/@types/firefox-webext-browser/-/firefox-webext-browser-82.0.0.tgz#4d0f5cfebd7321d2cbf0ccfb6032570f0138b958"
integrity sha512-zKHePkjMx42KIUUZCPcUiyu1tpfQXH9VR4iDYfns3HvmKVJzt/TAFT+DFVroos8BI9RH78YgF3Hi/wlC6R6cKA==
"@types/fs-extra@^9.0.1":
version "9.0.1"
@ -5857,12 +5857,12 @@ lru-cache@^6.0.0:
dependencies:
yallist "^4.0.0"
m3u8stream@^0.8.0:
version "0.8.0"
resolved "https://registry.yarnpkg.com/m3u8stream/-/m3u8stream-0.8.0.tgz#025a63358ee32d7652bdc0a93f46078582ec5e96"
integrity sha512-vvSjdkBPdDHzVr2M+aIXbnYys4zX6m3UzxMaxBJr1PpE0e/3sawkLD4EEmz/q9hv87bleotR70cOWR3UBMtskw==
m3u8stream@^0.8.3:
version "0.8.3"
resolved "https://registry.yarnpkg.com/m3u8stream/-/m3u8stream-0.8.3.tgz#c4624e92b4240eb356d040c4a5e155586cf58108"
integrity sha512-0nAcdrF8YJKUkb6PzWdvGftTPyCVWgoiot1AkNVbPKTeIGsWs6DrOjifrJ0Zi8WQfQmD2SuVCjkYIOip12igng==
dependencies:
miniget "^2.0.1"
miniget "^4.0.0"
sax "^1.2.4"
make-dir@^3.0.0, make-dir@^3.0.2:
@ -6060,15 +6060,10 @@ min-indent@^1.0.0:
resolved "https://registry.yarnpkg.com/min-indent/-/min-indent-1.0.1.tgz#a63f681673b30571fbe8bc25686ae746eefa9869"
integrity sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==
miniget@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/miniget/-/miniget-2.0.1.tgz#e2188573317ad8239bab33f056aae64804fc8e47"
integrity sha512-MX+QfVIPAutz6c+T7WKuFKtjcw0nOyRRh1ubhTDD+z/e/pKcSAsfAV63aQKUgb1MFRT1GyfJeW53N5fHkX0wIA==
miniget@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/miniget/-/miniget-2.1.0.tgz#2dfb9ecb3a9a55d9dc682102f65fca2a06e3f5ca"
integrity sha512-fy9x3d/0oOIhkwAms6kgxTYkHwdELhMfgj+9a/aYZpJdTWIIWGta9aXHUtnzUn+LjBmRoTdPRQSi2hkmEvXk3A==
miniget@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/miniget/-/miniget-4.1.0.tgz#018cc1180d2fe4d45ed735ac6bd2ab7224e8bceb"
integrity sha512-kzhrNv5L7LlomwGmPGQsLQ2PnT1LeJJWfB0wNFGyv426gEM1gsfziBQmfkr6XOBA8EusZg9nowlNT5CbuKTjZg==
minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1:
version "1.0.1"
@ -8941,14 +8936,14 @@ yauzl@^2.10.0:
buffer-crc32 "~0.2.3"
fd-slicer "~1.1.0"
ytdl-core@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.0.3.tgz#9772dc6f7f0272534d50f50903022f8502ae44fa"
integrity sha512-+pM+EocvdHHTfH3xCr3c41cIm8bD7IE/wv/QKjaO7PwdLaaOMIj7xc/7yWwy9NwUDgIKA1YTotcn0qpQ0FVtMA==
ytdl-core@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.1.1.tgz#191fabf472c44f969fe3eca15cb4d1c094e46282"
integrity sha512-T2VIS64sHKdLLqvuTV7S4WyoUCZLdR7HOP/9jX1CyXKYUjKLFP9UpVIFH0ZUvFSmK48eNFErWLOO5dGouwqztQ==
dependencies:
html-entities "^1.3.1"
m3u8stream "^0.8.0"
miniget "^2.1.0"
m3u8stream "^0.8.3"
miniget "^4.0.0"
sax "^1.1.3"
zip-stream@^4.0.0: