mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-17 02:17:03 -04:00
DeepLink & YTAdblock Fixes
Co-Authored-By: Viktor Fedorov <impqxr@gmail.com> Co-Authored-By: Henry <cootshk@duck.com>
This commit is contained in:
parent
856b66af63
commit
bb0b4897b4
4 changed files with 42 additions and 42 deletions
|
@ -4,22 +4,35 @@
|
|||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { Devs } from "@utils/constants";
|
||||
import { Devs, EquicordDevs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
|
||||
export default definePlugin({
|
||||
name: "DisableDeepLinks",
|
||||
description: "Disables Discord's stupid deep linking feature which tries to force you to use their Desktop App",
|
||||
authors: [Devs.Ven],
|
||||
authors: [Devs.Ven, EquicordDevs.Cootshk],
|
||||
required: true,
|
||||
|
||||
noop: () => { },
|
||||
acceptInvite: () => {
|
||||
open(document.location.href.replace(/invite/, "app/invite-with-guild-onboarding"), "_self");
|
||||
},
|
||||
|
||||
patches: [{
|
||||
find: /\.openNativeAppModal\(.{0,50}?\.DEEP_LINK/,
|
||||
replacement: {
|
||||
match: /\i\.\i\.openNativeAppModal/,
|
||||
replace: "$self.noop",
|
||||
patches: [
|
||||
{
|
||||
find: /\.openNativeAppModal\(.{0,50}?\.DEEP_LINK/,
|
||||
replacement: {
|
||||
match: /\i\.\i\.openNativeAppModal/,
|
||||
replace: "$self.noop",
|
||||
}
|
||||
},
|
||||
{ // This says that it has no effect, but it does
|
||||
find: /openApp\(/,
|
||||
replacement: {
|
||||
match: /\i\.\i\.launch\(\i,\i=>\{\i\.\i\.dispatch\(\i\?\{.*?\}:\{.*?\}\)\}\)/,
|
||||
replace: "$self.acceptInvite()",
|
||||
},
|
||||
all: true
|
||||
}
|
||||
}]
|
||||
]
|
||||
});
|
||||
|
|
|
@ -5,16 +5,27 @@
|
|||
*/
|
||||
|
||||
import { RendererSettings } from "@main/settings";
|
||||
import { app } from "electron";
|
||||
import { app, WebFrameMain } from "electron";
|
||||
import adguard from "file://adguard.js?minify";
|
||||
|
||||
type YoutubeFrame = WebFrameMain & { executed?: boolean; };
|
||||
|
||||
app.on("browser-window-created", (_, win) => {
|
||||
let watchTogetherFrame: YoutubeFrame | null = null;
|
||||
win.webContents.on("frame-created", (_, { frame }) => {
|
||||
frame?.once("dom-ready", () => {
|
||||
if (!RendererSettings.store.plugins?.YoutubeAdblock?.enabled) return;
|
||||
|
||||
if (frame.url.includes("youtube.com/embed/") || (frame.url.includes("discordsays") && frame.url.includes("youtube.com"))) {
|
||||
if (frame.url.includes("youtube.com/embed")) {
|
||||
frame.executeJavaScript(adguard);
|
||||
} else if (frame.url.includes("880218394199220334.discordsays.com/")) {
|
||||
watchTogetherFrame = frame;
|
||||
} else if (watchTogetherFrame && frame.top?.frames.includes(watchTogetherFrame)) {
|
||||
const youtubeEmbed = watchTogetherFrame.frames.find(frame => frame.url.includes("youtube.com/embed/")) as YoutubeFrame | undefined;
|
||||
if (youtubeEmbed !== undefined && youtubeEmbed.executed === undefined) {
|
||||
youtubeEmbed.executed = true;
|
||||
youtubeEmbed.executeJavaScript(adguard);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue