mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-14 09:03: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
|
@ -10,7 +10,7 @@ import { Devs } from "@utils/constants";
|
||||||
import { getCurrentChannel } from "@utils/discord";
|
import { getCurrentChannel } from "@utils/discord";
|
||||||
import { ModalCloseButton, ModalContent, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
import { ModalCloseButton, ModalContent, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
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 { Message } from "discord-types/general";
|
||||||
|
|
||||||
import { QuoteIcon } from "./components";
|
import { QuoteIcon } from "./components";
|
||||||
|
@ -49,7 +49,6 @@ let recentmessage: Message;
|
||||||
let grayscale;
|
let grayscale;
|
||||||
let setStyle: ImageStyle = ImageStyle.inspirational;
|
let setStyle: ImageStyle = ImageStyle.inspirational;
|
||||||
let customMessage: string = "";
|
let customMessage: string = "";
|
||||||
let isUserCustomCapable = false;
|
|
||||||
|
|
||||||
enum userIDOptions {
|
enum userIDOptions {
|
||||||
displayName,
|
displayName,
|
||||||
|
@ -89,14 +88,7 @@ const preparingSentence: string[] = [];
|
||||||
const lines: string[] = [];
|
const lines: string[] = [];
|
||||||
|
|
||||||
async function createQuoteImage(avatarUrl: string, quoteOld: string, grayScale: boolean): Promise<Blob> {
|
async function createQuoteImage(avatarUrl: string, quoteOld: string, grayScale: boolean): Promise<Blob> {
|
||||||
let quote;
|
const quote = FixUpQuote(quoteOld);
|
||||||
|
|
||||||
if (isUserCustomCapable && customMessage.length > 0) {
|
|
||||||
quote = FixUpQuote(customMessage);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
quote = FixUpQuote(quoteOld);
|
|
||||||
}
|
|
||||||
const canvas = document.createElement("canvas");
|
const canvas = document.createElement("canvas");
|
||||||
const ctx = canvas.getContext("2d");
|
const ctx = canvas.getContext("2d");
|
||||||
|
|
||||||
|
@ -194,13 +186,7 @@ function registerStyleChange(style) {
|
||||||
GeneratePreview();
|
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) {
|
function QuoteModal(props: ModalProps) {
|
||||||
setIsUserCustomCapable();
|
|
||||||
const [gray, setGray] = useState(true);
|
const [gray, setGray] = useState(true);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
grayscale = gray;
|
grayscale = gray;
|
||||||
|
@ -226,13 +212,6 @@ function QuoteModal(props: ModalProps) {
|
||||||
<ModalContent scrollbarType="none">
|
<ModalContent scrollbarType="none">
|
||||||
<img alt="" src="" id={"quoterPreview"} style={{ borderRadius: "20px", width: "100%" }}></img>
|
<img alt="" src="" id={"quoterPreview"} style={{ borderRadius: "20px", width: "100%" }}></img>
|
||||||
<br></br><br></br>
|
<br></br><br></br>
|
||||||
{isUserCustomCapable &&
|
|
||||||
(
|
|
||||||
<>
|
|
||||||
<TextInput onChange={setCustom} value={custom} placeholder="Custom Message"></TextInput>
|
|
||||||
<br />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
<Switch value={gray} onChange={setGray}>Grayscale</Switch>
|
<Switch value={gray} onChange={setGray}>Grayscale</Switch>
|
||||||
<Select look={1}
|
<Select look={1}
|
||||||
options={Object.keys(ImageStyle).filter(key => isNaN(parseInt(key, 10))).map(key => ({
|
options={Object.keys(ImageStyle).filter(key => isNaN(parseInt(key, 10))).map(key => ({
|
||||||
|
@ -278,14 +257,7 @@ async function GeneratePreview() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateFileNamePreview(message) {
|
function generateFileNamePreview(message) {
|
||||||
let words;
|
const words = message.split(" ");
|
||||||
|
|
||||||
if (isUserCustomCapable && customMessage.length) {
|
|
||||||
words = customMessage.split(" ");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
words = message.split(" ");
|
|
||||||
}
|
|
||||||
let preview;
|
let preview;
|
||||||
if (words.length >= 6) {
|
if (words.length >= 6) {
|
||||||
preview = words.slice(0, 6).join(" ");
|
preview = words.slice(0, 6).join(" ");
|
||||||
|
|
|
@ -4,22 +4,35 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs, EquicordDevs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "DisableDeepLinks",
|
name: "DisableDeepLinks",
|
||||||
description: "Disables Discord's stupid deep linking feature which tries to force you to use their Desktop App",
|
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,
|
required: true,
|
||||||
|
|
||||||
noop: () => { },
|
noop: () => { },
|
||||||
|
acceptInvite: () => {
|
||||||
|
open(document.location.href.replace(/invite/, "app/invite-with-guild-onboarding"), "_self");
|
||||||
|
},
|
||||||
|
|
||||||
patches: [{
|
patches: [
|
||||||
|
{
|
||||||
find: /\.openNativeAppModal\(.{0,50}?\.DEEP_LINK/,
|
find: /\.openNativeAppModal\(.{0,50}?\.DEEP_LINK/,
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /\i\.\i\.openNativeAppModal/,
|
match: /\i\.\i\.openNativeAppModal/,
|
||||||
replace: "$self.noop",
|
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 { RendererSettings } from "@main/settings";
|
||||||
import { app } from "electron";
|
import { app, WebFrameMain } from "electron";
|
||||||
import adguard from "file://adguard.js?minify";
|
import adguard from "file://adguard.js?minify";
|
||||||
|
|
||||||
|
type YoutubeFrame = WebFrameMain & { executed?: boolean; };
|
||||||
|
|
||||||
app.on("browser-window-created", (_, win) => {
|
app.on("browser-window-created", (_, win) => {
|
||||||
|
let watchTogetherFrame: YoutubeFrame | null = null;
|
||||||
win.webContents.on("frame-created", (_, { frame }) => {
|
win.webContents.on("frame-created", (_, { frame }) => {
|
||||||
frame?.once("dom-ready", () => {
|
frame?.once("dom-ready", () => {
|
||||||
if (!RendererSettings.store.plugins?.YoutubeAdblock?.enabled) return;
|
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);
|
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: {
|
Campfire: {
|
||||||
name: "Campfire",
|
name: "Campfire",
|
||||||
id: 376414446840578081n,
|
id: 376414446840578081n,
|
||||||
}
|
},
|
||||||
|
Cootshk: {
|
||||||
|
name: "Cootshk",
|
||||||
|
id: 921605971577548820n,
|
||||||
|
},
|
||||||
} satisfies Record<string, Dev>);
|
} satisfies Record<string, Dev>);
|
||||||
|
|
||||||
// iife so #__PURE__ works correctly
|
// iife so #__PURE__ works correctly
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue