new plugin YoutubeAdblock: blocks ads in embeds (formerly WatchTogetherAdblock)

This commit is contained in:
Vendicated 2024-08-01 14:49:18 +02:00
parent 2658459a98
commit 0f8d21a846
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18
4 changed files with 9 additions and 6 deletions

View file

@ -1,6 +1,7 @@
# WatchTogetherAdblock # WatchTogetherAdblock
Block ads in the YouTube WatchTogether activity via AdGuard Block ads in YouTube embeds and the WatchTogether activity via AdGuard
Note that this only works for yourself, other users in the activity will still see ads. Note that this only works for yourself, other users in the activity will still see ads.
Powered by a modified version of [Adguard's BlockYoutubeAdsShortcut](https://github.com/AdguardTeam/BlockYouTubeAdsShortcut) Powered by a modified version of [Adguard's BlockYoutubeAdsShortcut](https://github.com/AdguardTeam/BlockYouTubeAdsShortcut)

View file

@ -4,12 +4,14 @@
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
import { migratePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin from "@utils/types"; import definePlugin from "@utils/types";
// The entire code of this plugin can be found in native.ts // The entire code of this plugin can be found in native.ts
migratePluginSettings("YoutubeAdblock", "WatchTogetherAdblock");
export default definePlugin({ export default definePlugin({
name: "WatchTogetherAdblock", name: "YoutubeAdblock",
description: "Block ads in the YouTube WatchTogether activity via AdGuard", description: "Block ads in YouTube embeds and the WatchTogether activity via AdGuard",
authors: [Devs.ImLvna], authors: [Devs.ImLvna, Devs.Ven],
}); });

View file

@ -11,9 +11,9 @@ import adguard from "file://adguard.js?minify";
app.on("browser-window-created", (_, win) => { app.on("browser-window-created", (_, win) => {
win.webContents.on("frame-created", (_, { frame }) => { win.webContents.on("frame-created", (_, { frame }) => {
frame.once("dom-ready", () => { frame.once("dom-ready", () => {
if (frame.url.includes("discordsays") && frame.url.includes("youtube.com")) { if (!RendererSettings.store.plugins?.YoutubeAdblock?.enabled) return;
if (!RendererSettings.store.plugins?.WatchTogetherAdblock?.enabled) return;
if (frame.url.includes("youtube.com/embed/") || (frame.url.includes("discordsays") && frame.url.includes("youtube.com"))) {
frame.executeJavaScript(adguard); frame.executeJavaScript(adguard);
} }
}); });