Merge branch 'dev' into feat/translation

This commit is contained in:
Lewis Crichton 2023-12-27 16:40:12 +00:00 committed by GitHub
commit 8c3aa368d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 58 additions and 49 deletions

View file

@ -350,7 +350,7 @@ function runTime(token: string) {
let invalidEntryPoint = false; let invalidEntryPoint = false;
for (const id of chunkIds) { for (const id of chunkIds) {
if (!wreq.u(id)) continue; if (wreq.u(id) == null || wreq.u(id) === "undefined.js") continue;
const isWasm = await fetch(wreq.p + wreq.u(id)) const isWasm = await fetch(wreq.p + wreq.u(id))
.then(r => r.text()) .then(r => r.text())
@ -376,9 +376,22 @@ function runTime(token: string) {
} catch (err) { } } catch (err) { }
} }
const allChunks = Function("return " + (wreq.u.toString().match(/(?<=\()\{.+?\}/s)?.[0] ?? "null"))() as Record<string | number, string[]> | null; // Matches "id" or id:
if (!allChunks) throw new Error("Failed to get all chunks"); const chunkIdRegex = /(?:"(\d+?)")|(?:(\d+?):)/g;
const chunksLeft = Object.keys(allChunks).filter(id => { const wreqU = wreq.u.toString();
const allChunks = [] as string[];
let currentMatch: RegExpExecArray | null;
while ((currentMatch = chunkIdRegex.exec(wreqU)) != null) {
const id = currentMatch[1] ?? currentMatch[2];
if (id == null) continue;
allChunks.push(id);
}
if (allChunks.length === 0) throw new Error("Failed to get all chunks");
const chunksLeft = allChunks.filter(id => {
return !(validChunks.has(id) || invalidChunks.has(id)); return !(validChunks.has(id) || invalidChunks.has(id));
}); });

View file

@ -45,8 +45,8 @@ export default definePlugin({
{ {
find: ".embedWrapper,embed", find: ".embedWrapper,embed",
replacement: [{ replacement: [{
match: /\.embedWrapper/g, match: /\.embedWrapper(?=.+?channel_id:(\i)\.id)/g,
replace: "$&+(this.props.channel.nsfw?' vc-nsfw-img':'')" replace: "$&+($1.nsfw?' vc-nsfw-img':'')"
}] }]
} }
], ],

View file

@ -147,7 +147,7 @@ export default definePlugin({
replacement: [ replacement: [
// patch componentDidMount to replace embed thumbnail and title // patch componentDidMount to replace embed thumbnail and title
{ {
match: /render\(\)\{let\{embed:/, match: /render\(\)\{.{0,30}let\{embed:/,
replace: "componentDidMount=$self.embedDidMount;$&" replace: "componentDidMount=$self.embedDidMount;$&"
}, },

View file

@ -1,25 +0,0 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2023 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
export default definePlugin({
name: "FixImagesQuality",
description: "Fixes the quality of images in the chat being horrible.",
authors: [Devs.Nuckyz],
patches: [
{
find: "handleImageLoad=",
replacement: [
{
match: /(?<=getSrc\(\i\){.+?return )\i\.SUPPORTS_WEBP.+?:(?=\i&&\(\i="png"\))/,
replace: ""
}
]
}
]
});

View file

@ -16,10 +16,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { definePluginSettings } from "@api/Settings";
import { disableStyle, enableStyle } from "@api/Styles"; import { disableStyle, enableStyle } from "@api/Styles";
import ErrorBoundary from "@components/ErrorBoundary"; import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { findComponentByCodeLazy } from "@webpack"; import { findComponentByCodeLazy } from "@webpack";
import { StatusSettingsStores } from "@webpack/common"; import { StatusSettingsStores } from "@webpack/common";
@ -28,22 +29,31 @@ import style from "./style.css?managed";
const Button = findComponentByCodeLazy("Button.Sizes.NONE,disabled:"); const Button = findComponentByCodeLazy("Button.Sizes.NONE,disabled:");
function makeIcon(showCurrentGame?: boolean) { function makeIcon(showCurrentGame?: boolean) {
const controllerIcon = "M3.06 20.4q-1.53 0-2.37-1.065T.06 16.74l1.26-9q.27-1.8 1.605-2.97T6.06 3.6h11.88q1.8 0 3.135 1.17t1.605 2.97l1.26 9q.21 1.53-.63 2.595T20.94 20.4q-.63 0-1.17-.225T18.78 19.5l-2.7-2.7H7.92l-2.7 2.7q-.45.45-.99.675t-1.17.225Zm14.94-7.2q.51 0 .855-.345T19.2 12q0-.51-.345-.855T18 10.8q-.51 0-.855.345T16.8 12q0 .51.345 .855T18 13.2Zm-2.4-3.6q.51 0 .855-.345T16.8 8.4q0-.51-.345-.855T15.6 7.2q-.51 0-.855.345T14.4 8.4q0 .51.345 .855T15.6 9.6ZM6.9 13.2h1.8v-2.1h2.1v-1.8h-2.1v-2.1h-1.8v2.1h-2.1v1.8h2.1v2.1Z"; const { oldIcon } = settings.use(["oldIcon"]);
const redLinePath = !oldIcon
? "M22.7 2.7a1 1 0 0 0-1.4-1.4l-20 20a1 1 0 1 0 1.4 1.4Z"
: "M23 2.27 21.73 1 1 21.73 2.27 23 23 2.27Z";
const maskBlackPath = !oldIcon
? "M23.27 4.73 19.27 .73 -.27 20.27 3.73 24.27Z"
: "M23.27 4.54 19.46.73 .73 19.46 4.54 23.27 23.27 4.54Z";
return function () { return function () {
return ( return (
<svg width="20" height="20" viewBox="0 0 24 24"> <svg width="20" height="20" viewBox="0 0 24 24">
{showCurrentGame ? ( <path
<path fill="currentColor" d={controllerIcon} /> fill={!showCurrentGame && !oldIcon ? "var(--status-danger)" : "currentColor"}
) : ( mask={!showCurrentGame ? "url(#gameActivityMask)" : void 0}
<> d="M3.06 20.4q-1.53 0-2.37-1.065T.06 16.74l1.26-9q.27-1.8 1.605-2.97T6.06 3.6h11.88q1.8 0 3.135 1.17t1.605 2.97l1.26 9q.21 1.53-.63 2.595T20.94 20.4q-.63 0-1.17-.225T18.78 19.5l-2.7-2.7H7.92l-2.7 2.7q-.45.45-.99.675t-1.17.225Zm14.94-7.2q.51 0 .855-.345T19.2 12q0-.51-.345-.855T18 10.8q-.51 0-.855.345T16.8 12q0 .51.345 .855T18 13.2Zm-2.4-3.6q.51 0 .855-.345T16.8 8.4q0-.51-.345-.855T15.6 7.2q-.51 0-.855.345T14.4 8.4q0 .51.345 .855T15.6 9.6ZM6.9 13.2h1.8v-2.1h2.1v-1.8h-2.1v-2.1h-1.8v2.1h-2.1v1.8h2.1v2.1Z"
<mask id="gameActivityMask" > />
{!showCurrentGame && <>
<path fill="var(--status-danger)" d={redLinePath} />
<mask id="gameActivityMask">
<rect fill="white" x="0" y="0" width="24" height="24" /> <rect fill="white" x="0" y="0" width="24" height="24" />
<path fill="black" d="M23.27 4.73 19.27 .73 -.27 20.27 3.73 24.27Z" /> <path fill="black" d={maskBlackPath} />
</mask> </mask>
<path fill="var(--status-danger)" mask="url(#gameActivityMask)" d={controllerIcon} /> </>}
<path fill="var(--status-danger)" d="M22.7 2.7a1 1 0 0 0-1.4-1.4l-20 20a1 1 0 1 0 1.4 1.4Z" />
</>
)}
</svg> </svg>
); );
}; };
@ -63,10 +73,19 @@ function GameActivityToggleButton() {
); );
} }
const settings = definePluginSettings({
oldIcon: {
type: OptionType.BOOLEAN,
description: "Use the old icon style before Discord icon redesign",
default: false
}
});
export default definePlugin({ export default definePlugin({
name: "GameActivityToggle", name: "GameActivityToggle",
description: "Adds a button next to the mic and deafen button to toggle game activity.", description: "Adds a button next to the mic and deafen button to toggle game activity.",
authors: [Devs.Nuckyz, Devs.RuukuLada], authors: [Devs.Nuckyz, Devs.RuukuLada],
settings,
patches: [ patches: [
{ {

View file

@ -328,6 +328,7 @@ export default definePlugin({
// Attachment renderer // Attachment renderer
// Module 96063 // Module 96063
find: ".removeAttachmentHoverButton", find: ".removeAttachmentHoverButton",
group: true,
replacement: [ replacement: [
{ {
match: /(className:\i,attachment:\i),/, match: /(className:\i,attachment:\i),/,

View file

@ -27,8 +27,8 @@ export default definePlugin({
{ {
find: ".nsfwAllowed=null", find: ".nsfwAllowed=null",
replacement: { replacement: {
match: /(\w+)\.nsfwAllowed=/, match: /(?<=\.nsfwAllowed=)null!==.+?(?=[,;])/,
replace: "$1.nsfwAllowed=true;", replace: "!0",
}, },
}, },
], ],

View file

@ -33,6 +33,7 @@ import { VerifiedIcon } from "./VerifiedIcon";
const Section = findComponentByCodeLazy(".lastSection", "children:"); const Section = findComponentByCodeLazy(".lastSection", "children:");
const ThemeStore = findStoreLazy("ThemeStore"); const ThemeStore = findStoreLazy("ThemeStore");
const platformHooks: { useLegacyPlatformType(platform: string): string; } = findByPropsLazy("useLegacyPlatformType");
const platforms: { get(type: string): ConnectionPlatform; } = findByPropsLazy("isSupported", "getByUrl"); const platforms: { get(type: string): ConnectionPlatform; } = findByPropsLazy("isSupported", "getByUrl");
const getTheme: (user: User, displayProfile: any) => any = findByCodeLazy(',"--profile-gradient-primary-color"'); const getTheme: (user: User, displayProfile: any) => any = findByCodeLazy(',"--profile-gradient-primary-color"');
@ -111,7 +112,7 @@ function ConnectionsComponent({ id, theme }: { id: string, theme: string; }) {
} }
function CompactConnectionComponent({ connection, theme }: { connection: Connection, theme: string; }) { function CompactConnectionComponent({ connection, theme }: { connection: Connection, theme: string; }) {
const platform = platforms.get(connection.type); const platform = platforms.get(platformHooks.useLegacyPlatformType(connection.type));
const url = platform.getPlatformUserUrl?.(connection); const url = platform.getPlatformUserUrl?.(connection);
const img = ( const img = (