mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-10 07:03:06 -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
|
@ -10,7 +10,7 @@ import { Devs } from "@utils/constants";
|
|||
import { getCurrentChannel } from "@utils/discord";
|
||||
import { ModalCloseButton, ModalContent, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { Button, Menu, Select, Switch, Text, TextInput, UploadHandler, useEffect, UserStore, useState } from "@webpack/common";
|
||||
import { Button, Menu, Select, Switch, Text, UploadHandler, useEffect, useState } from "@webpack/common";
|
||||
import { Message } from "discord-types/general";
|
||||
|
||||
import { QuoteIcon } from "./components";
|
||||
|
@ -49,7 +49,6 @@ let recentmessage: Message;
|
|||
let grayscale;
|
||||
let setStyle: ImageStyle = ImageStyle.inspirational;
|
||||
let customMessage: string = "";
|
||||
let isUserCustomCapable = false;
|
||||
|
||||
enum userIDOptions {
|
||||
displayName,
|
||||
|
@ -89,14 +88,7 @@ const preparingSentence: string[] = [];
|
|||
const lines: string[] = [];
|
||||
|
||||
async function createQuoteImage(avatarUrl: string, quoteOld: string, grayScale: boolean): Promise<Blob> {
|
||||
let quote;
|
||||
|
||||
if (isUserCustomCapable && customMessage.length > 0) {
|
||||
quote = FixUpQuote(customMessage);
|
||||
}
|
||||
else {
|
||||
quote = FixUpQuote(quoteOld);
|
||||
}
|
||||
const quote = FixUpQuote(quoteOld);
|
||||
const canvas = document.createElement("canvas");
|
||||
const ctx = canvas.getContext("2d");
|
||||
|
||||
|
@ -194,13 +186,7 @@ function registerStyleChange(style) {
|
|||
GeneratePreview();
|
||||
}
|
||||
|
||||
async function setIsUserCustomCapable() {
|
||||
const allowList: string[] = await fetch("https://equicord.org/quoter").then(e => e.json()); // Override for memes - IF THIS IS ABUSED WILL WE TAKEN AWAY
|
||||
isUserCustomCapable = allowList.includes(UserStore.getCurrentUser().id);
|
||||
}
|
||||
|
||||
function QuoteModal(props: ModalProps) {
|
||||
setIsUserCustomCapable();
|
||||
const [gray, setGray] = useState(true);
|
||||
useEffect(() => {
|
||||
grayscale = gray;
|
||||
|
@ -226,13 +212,6 @@ function QuoteModal(props: ModalProps) {
|
|||
<ModalContent scrollbarType="none">
|
||||
<img alt="" src="" id={"quoterPreview"} style={{ borderRadius: "20px", width: "100%" }}></img>
|
||||
<br></br><br></br>
|
||||
{isUserCustomCapable &&
|
||||
(
|
||||
<>
|
||||
<TextInput onChange={setCustom} value={custom} placeholder="Custom Message"></TextInput>
|
||||
<br />
|
||||
</>
|
||||
)}
|
||||
<Switch value={gray} onChange={setGray}>Grayscale</Switch>
|
||||
<Select look={1}
|
||||
options={Object.keys(ImageStyle).filter(key => isNaN(parseInt(key, 10))).map(key => ({
|
||||
|
@ -278,14 +257,7 @@ async function GeneratePreview() {
|
|||
}
|
||||
|
||||
function generateFileNamePreview(message) {
|
||||
let words;
|
||||
|
||||
if (isUserCustomCapable && customMessage.length) {
|
||||
words = customMessage.split(" ");
|
||||
}
|
||||
else {
|
||||
words = message.split(" ");
|
||||
}
|
||||
const words = message.split(" ");
|
||||
let preview;
|
||||
if (words.length >= 6) {
|
||||
preview = words.slice(0, 6).join(" ");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1065,7 +1065,11 @@ export const EquicordDevs = Object.freeze({
|
|||
Campfire: {
|
||||
name: "Campfire",
|
||||
id: 376414446840578081n,
|
||||
}
|
||||
},
|
||||
Cootshk: {
|
||||
name: "Cootshk",
|
||||
id: 921605971577548820n,
|
||||
},
|
||||
} satisfies Record<string, Dev>);
|
||||
|
||||
// iife so #__PURE__ works correctly
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue