Skip to content

Commit 5d173f3

Browse files
[Copier] Deprecation fix (#478)
Co-authored-by: Dominik <me@domi-btnr.dev>
1 parent 84643dc commit 5d173f3

File tree

3 files changed

+33
-55
lines changed

3 files changed

+33
-55
lines changed

Copier/index.jsx

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,32 @@
1-
import {Patcher, ReactUtils, UI} from "@api";
2-
import * as ContextMenus from "./menus";
3-
import Styles from "@styles";
4-
import Webpack, {Tooltip} from "./modules/webpack";
5-
import {copy, findInTree, onceAdded} from "./modules/utils";
6-
import config from "@manifest";
7-
import React from "react";
8-
import CopyIcon from "./components/icons/copy";
9-
101
import "./button.css";
112
import "./changelog.css";
3+
4+
import React from "react";
5+
6+
import {Patcher, ReactUtils} from "@api";
7+
import manifest from "@manifest";
8+
import Styles from "@styles";
9+
10+
import showChangelog from "../common/Changelog";
1211
import CopyButton from "./components/copybutton";
1312
import SettingsPanel from "./components/settings";
14-
import Settings from "./modules/settings";
13+
import * as ContextMenus from "./menus";
14+
import Webpack, { Tooltip } from "./modules/webpack";
15+
import {findInTree, onceAdded} from "./modules/utils";
16+
import CopyIcon from "./components/icons/copy";
1517

1618
export default class Copier {
1719
flush = new Set();
18-
19-
maybeShowChangelog() {
20-
if (config.version === Settings.get("latestUsedVersion")) return;
21-
22-
const items = config.changelog.map(item => (
23-
<div className={"copier-changelog-item " + "item-changelog-" + item.type}>
24-
<h4 className="copier-changelog-header">{item.type}</h4>
25-
{item.items.map(i => <span>{i}</span>)}
26-
</div>
27-
));
28-
29-
"changelogImage" in config && items.unshift(
30-
<img className="copier-changelog-banner" src={config.changelogImage} />
31-
);
32-
33-
Settings.set("latestUsedVersion", config.version);
34-
35-
const formatter = new Intl.DateTimeFormat(document.documentElement.lang, {month: "long", day: "numeric", year: "numeric"});
36-
UI.alert(<div className="copier-title-wrap">
37-
<h1>What's New - {config.name}</h1>
38-
<span>{formatter.format(new Date(config.changelogDate))}</span>
39-
</div>, items);
40-
}
41-
4220
getSettingsPanel() {
4321
return (
4422
<SettingsPanel />
4523
);
4624
}
4725

4826
start() {
49-
this.controller = new AbortController();
5027
Styles.load();
28+
showChangelog(manifest);
29+
this.controller = new AbortController();
5130

5231
for (const id in ContextMenus) {
5332
try {
@@ -58,13 +37,12 @@ export default class Copier {
5837
}
5938
}
6039

61-
this.patchAboutMe();
40+
// this.patchAboutMe();
6241
this.patchToolbar();
63-
this.maybeShowChangelog();
6442
}
6543

6644
patchAboutMe() {
67-
const [module, key] = Webpack.getMangled(m => m?.toString?.().includes("USER_POPOUT_ABOUT_ME"));
45+
const module = Webpack.getBySource(['animUserProfileSidebarateOnHoverOrFocusOnly','61W33d'])
6846

6947
const CopyButton = React.memo(({onClick}) => (
7048
<Tooltip text="Copy About Me" tooltipClassName="copier-tooltip" position="top">
@@ -76,7 +54,8 @@ export default class Copier {
7654
</Tooltip>
7755
));
7856

79-
Patcher.after(module, key, (_, [{bio}], res) => {
57+
Patcher.after(module, "Z", (_, [{bio}], res) => {
58+
console.log(res)
8059
const title = findInTree(res, e => e?.variant && Array.isArray(e.children));
8160

8261
if (!title) return res;;

Copier/modules/webpack.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as Api from "@api";
33
const {Webpack, Webpack: {Filters}} = Api;
44

55
export const getByProps = (...props) => {
6-
return Webpack.getModule(Filters.byProps(...props));
6+
return Webpack.getModule(Filters.byKeys(...props));
77
};
88

99
export const getBulk = (...queries) => {
@@ -23,6 +23,11 @@ export const getMangled = function* (filter, target = null) {
2323
yield target && Object.keys(target).find(k => filter(target[k]));
2424
};
2525

26+
export const getBySource = function(sources) {
27+
const filters = Filters.combine(...sources.map(x => Filters.bySource(x)))
28+
return Webpack.getModule(filters);
29+
};
30+
2631
export const getModule = Webpack.getModule;
2732

2833
export default {
@@ -31,7 +36,8 @@ export default {
3136
getMangled,
3237
getByProps,
3338
getStore,
34-
getBulk
39+
getBulk,
40+
getBySource
3541
};
3642

3743
export {Filters};

Copier/package.json

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
{
22
"name": "Copier",
3-
"authors": [
4-
{
5-
"name": "Strencher",
6-
"discord_id": "415849376598982656",
7-
"github_username": "Strencher",
8-
"twitter_username": "Strencher3"
9-
}
10-
],
11-
"version": "1.6.1",
3+
"version": "1.6.2",
4+
"author": "Strencher",
5+
"authorId": "415849376598982656",
126
"description": "Allows you to copy certain stuff with custom options.",
13-
"github": "https://github.com/Strencher/BetterDiscordStuff/blob/master/Copier/Copier.plugin.js",
14-
"github_raw": "https://raw.githubusercontent.com/Strencher/BetterDiscordStuff/master/Copier/Copier.plugin.js",
15-
"changelogImage": "https://cdn.discordapp.com/attachments/672786846018961418/1053059354552696932/20th-century-fox-intro.png",
16-
"changelogDate": "2023-02-11T17:25:37.796Z",
7+
"source": "https://github.com/Strencher/BetterDiscordStuff/blob/master/Copier/Copier.plugin.js",
8+
"invite": "gvA2ree",
179
"changelog": [
1810
{
1911
"type": "fixed",
@@ -22,5 +14,6 @@
2214
"The plugin has returned."
2315
]
2416
}
25-
]
17+
],
18+
"changelogDate": "2026-01-16"
2619
}

0 commit comments

Comments
 (0)