From dda18a72afaf07c5971833cab79fedf335061385 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Fri, 15 Oct 2021 14:38:09 +0300 Subject: [PATCH 1/2] new auto confirm when paused --- package.json | 4 +--- plugins/auto-confirm-when-paused/front.js | 12 ------------ preload.js | 10 ++++++---- providers/song-controls-front.js | 18 ------------------ providers/song-controls.js | 2 +- readme.md | 2 +- yarn.lock | 4 ---- 7 files changed, 9 insertions(+), 43 deletions(-) delete mode 100644 plugins/auto-confirm-when-paused/front.js delete mode 100644 providers/song-controls-front.js diff --git a/package.json b/package.json index 6920b186b4..a428d1dec6 100644 --- a/package.json +++ b/package.json @@ -52,9 +52,8 @@ "build:mac": "yarn run clean && electron-builder --mac", "build:win": "yarn run clean && electron-builder --win", "lint": "xo", - "plugins": "yarn run plugin:adblocker && yarn run plugin:autoconfirm", + "plugins": "yarn run plugin:adblocker", "plugin:adblocker": "rimraf plugins/adblocker/ad-blocker-engine.bin && node plugins/adblocker/blocker.js", - "plugin:autoconfirm": "yarn run generate:package YoutubeNonStop", "release:linux": "yarn run clean && electron-builder --linux -p always -c.snap.publish=github", "release:mac": "yarn run clean && electron-builder --mac -p always", "release:win": "yarn run clean && electron-builder --win -p always" @@ -67,7 +66,6 @@ "@cliqz/adblocker-electron": "^1.22.5", "@ffmpeg/core": "^0.10.0", "@ffmpeg/ffmpeg": "^0.10.0", - "YoutubeNonStop": "git://github.com/lawfx/YoutubeNonStop.git#v0.9.0", "async-mutex": "^0.3.1", "browser-id3-writer": "^4.4.0", "chokidar": "^3.5.2", diff --git a/plugins/auto-confirm-when-paused/front.js b/plugins/auto-confirm-when-paused/front.js deleted file mode 100644 index 0ead302ee0..0000000000 --- a/plugins/auto-confirm-when-paused/front.js +++ /dev/null @@ -1,12 +0,0 @@ -// Define global chrome object to be compliant with the extension code -global.chrome = { - runtime: { - getManifest: () => ({ - version: 1 - }) - } -}; - -module.exports = () => { - require("YoutubeNonStop/autoconfirm.js"); -}; diff --git a/preload.js b/preload.js index 5a09c84548..3451be1809 100644 --- a/preload.js +++ b/preload.js @@ -5,7 +5,6 @@ const { remote } = require("electron"); const config = require("./config"); const { fileExists } = require("./plugins/utils"); const setupFrontLogger = require("./providers/front-logger"); -const setupSongControl = require("./providers/song-controls-front"); const setupSongInfo = require("./providers/song-info-front"); const plugins = config.plugins.getEnabled(); @@ -41,13 +40,16 @@ document.addEventListener("DOMContentLoaded", () => { // inject song-info provider setupSongInfo(); - // inject song-control provider - setupSongControl(); - // inject front logger setupFrontLogger(); // Add action for reloading global.reload = () => remote.getCurrentWindow().webContents.loadURL(config.get("url")); + + // Block "You still there?" popup by setting last active time to date.now every 15min + const activityScript = document.createElement('script'); + activityScript.textContent = `setInterval(() => window._lact = Date.now(), 900000);`; + (document.head || document.documentElement).appendChild(activityScript); + activityScript.remove(); }); diff --git a/providers/song-controls-front.js b/providers/song-controls-front.js deleted file mode 100644 index 1860e7614e..0000000000 --- a/providers/song-controls-front.js +++ /dev/null @@ -1,18 +0,0 @@ -const { ipcRenderer } = require("electron"); - -let videoStream = document.querySelector(".video-stream"); -module.exports = () => { - ipcRenderer.on("playPause", () => { - if (!videoStream) { - videoStream = document.querySelector(".video-stream"); - } - - if (videoStream.paused) { - videoStream.play(); - } else { - videoStream.yns_pause ? - videoStream.yns_pause() : - videoStream.pause(); - } - }); -}; diff --git a/providers/song-controls.js b/providers/song-controls.js index 5d3ad953d2..7f43df11bb 100644 --- a/providers/song-controls.js +++ b/providers/song-controls.js @@ -12,7 +12,7 @@ module.exports = (win) => { // Playback previous: () => pressKey(win, "k"), next: () => pressKey(win, "j"), - playPause: () => win.webContents.send("playPause"), + playPause: () => pressKey(win, "space"), like: () => pressKey(win, "_"), dislike: () => pressKey(win, "+"), go10sBack: () => pressKey(win, "h"), diff --git a/readme.md b/readme.md index c47170c11a..46ef0e9ed3 100644 --- a/readme.md +++ b/readme.md @@ -35,7 +35,6 @@ Install the `youtube-music-bin` package from the AUR. For AUR installation instr ## Available plugins: - **Ad Blocker**: block all ads and tracking out of the box -- **Auto confirm when paused**: when the ["Continue Watching?"](https://user-images.githubusercontent.com/61631665/129977894-01c60740-7ec6-4bf0-9a2c-25da24491b0e.png) modal appears, automatically click "Yes" - **Disable autoplay**: makes every song start in "paused" mode - [**Discord**](https://discord.com/): show your friends what you listen to with [Rich Presence](https://user-images.githubusercontent.com/28219076/104362104-a7a0b980-5513-11eb-9744-bb89eabe0016.png) - **Downloader**: downloads MP3 [directly from the interface](https://user-images.githubusercontent.com/61631665/129977677-83a7d067-c192-45e1-98ae-b5a4927393be.png) [(youtube-dl)](https://github.com/ytdl-org/youtube-dl) @@ -51,6 +50,7 @@ Install the `youtube-music-bin` package from the AUR. For AUR installation instr - [**SponsorBlock**](https://github.com/ajayyy/SponsorBlock): skips non-music parts - **Taskbar media control**: control app from your [Windows taskbar](https://user-images.githubusercontent.com/78568641/111916130-24a35e80-8a82-11eb-80c8-5021c1aa27f4.png) - **Touchbar**: custom TouchBar layout for macOS +- **Auto confirm when paused** (Always Enabled): disable the ["Continue Watching?"](https://user-images.githubusercontent.com/61631665/129977894-01c60740-7ec6-4bf0-9a2c-25da24491b0e.png) popup that pause music after a certain time ## Dev diff --git a/yarn.lock b/yarn.lock index 743fcc5034..c64f6d204f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1523,10 +1523,6 @@ dependencies: "@wdio/logger" "6.10.10" -"YoutubeNonStop@git://github.com/lawfx/YoutubeNonStop.git#v0.9.0": - version "0.0.0" - resolved "git://github.com/lawfx/YoutubeNonStop.git#7b6b97b31bb3fd2078179660db0fd3fcc7062259" - abab@^2.0.3: version "2.0.5" resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.5.tgz#c0b678fb32d60fc1219c784d6a826fe385aeb79a" From 831b1ea8e12afde9bf31b2259efcc0eaeea30b45 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Sat, 23 Oct 2021 15:21:49 +0300 Subject: [PATCH 2/2] access window._lact directly --- preload.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/preload.js b/preload.js index 3451be1809..6f890e6a0c 100644 --- a/preload.js +++ b/preload.js @@ -47,9 +47,6 @@ document.addEventListener("DOMContentLoaded", () => { global.reload = () => remote.getCurrentWindow().webContents.loadURL(config.get("url")); - // Block "You still there?" popup by setting last active time to date.now every 15min - const activityScript = document.createElement('script'); - activityScript.textContent = `setInterval(() => window._lact = Date.now(), 900000);`; - (document.head || document.documentElement).appendChild(activityScript); - activityScript.remove(); + // Blocks the "Are You Still There?" popup by setting the last active time to Date.now every 15min + setInterval(() => window._lact = Date.now(), 900000); });