Skip to content

Commit f1eeb7e

Browse files
committed
23:11:44.88 - Wed 03/05/2025
1 parent a359bcc commit f1eeb7e

File tree

9 files changed

+861
-696
lines changed

9 files changed

+861
-696
lines changed

CopyImageLink/CopyImageLink.plugin.js

+22-29
Original file line numberDiff line numberDiff line change
@@ -20,67 +20,61 @@ const config = {
2020
}
2121
}
2222

23+
// common\Api.js
2324
const Api = new BdApi(config.info.name);
24-
2525
const UI = Api.UI;
2626
const DOM = Api.DOM;
2727
const React = Api.React;
2828
const Patcher = Api.Patcher;
29+
const Logger = Api.Logger;
30+
const Webpack = Api.Webpack;
2931

30-
const getModule = Api.Webpack.getModule;
32+
// common\Webpack.js
33+
const getModule = Webpack.getModule;
3134

35+
// @Modules\RenderLinkComponent
3236
const RenderLinkComponent = getModule(m => m.type?.toString?.().includes("MASKED_LINK"), { searchExports: false });
3337

38+
// common\Utils\Logger.js
39+
Logger.patchError = patchId => {
40+
console.error(`%c[${config.info.name}] %cCould not find module for %c[${patchId}]`, "color: #3a71c1;font-weight: bold;", "", "color: red;font-weight: bold;");
41+
};
42+
43+
// common\Utils.jsx
3444
function copy(data) {
3545
DiscordNative.clipboard.copy(data);
3646
}
3747

38-
const Logger = {
39-
error(...args) {
40-
this.p(console.error, ...args);
41-
},
42-
patch(patchId) {
43-
console.error(`%c[${config.info.name}] %c Error at %c[${patchId}]`, "color: #3a71c1;font-weight: bold;", "", "color: red;font-weight: bold;");
44-
},
45-
log(...args) {
46-
this.p(console.log, ...args);
47-
},
48-
p(target, ...args) {
49-
target(`%c[${config.info.name}]`, "color: #3a71c1;font-weight: bold;", ...args);
50-
}
51-
};
52-
48+
// common\Utils\Toast.js
5349
function showToast(content, type) {
5450
UI.showToast(`[${config.info.name}] ${content}`, { timeout: 5000, type });
5551
}
56-
5752
const Toast = {
5853
success(content) { showToast(content, "success"); },
5954
info(content) { showToast(content, "info"); },
6055
warning(content) { showToast(content, "warning"); },
6156
error(content) { showToast(content, "error"); }
6257
};
6358

59+
// src\CopyImageLink\components\CopyButtonComponent.jsx
6460
const CopyButtonComponent = ({ href }) => {
6561
return (
6662
React.createElement(React.Fragment, null, React.createElement('span', { className: "copyBtnSpan", }, "|"), React.createElement('a', {
67-
className: "copyBtn",
68-
onClick: () => {
69-
copy(href);
70-
Toast.success("Link Copied!");
71-
},
72-
}, "Copy link"
73-
74-
))
63+
className: "copyBtn",
64+
onClick: () => {
65+
copy(href);
66+
Toast.success("Link Copied!");
67+
},
68+
}, "Copy link"))
7569
);
7670
};
7771

72+
// src\CopyImageLink\index.jsx
7873
class CopyImageLink {
7974
start() {
8075
try {
81-
8276
DOM.addStyle(css);
83-
if (!RenderLinkComponent) return Logger.patch("RenderLinkComponent");
77+
if (!RenderLinkComponent) return Logger.patchError("RenderLinkComponent");
8478
Patcher.after(RenderLinkComponent, "type", (_, [{ className, href }], returnValue) => {
8579
if (!returnValue || !className?.startsWith("downloadLink") || !href) return;
8680
return [returnValue, React.createElement(CopyButtonComponent, { href: href, })];
@@ -89,7 +83,6 @@ class CopyImageLink {
8983
Logger.error(e);
9084
}
9185
}
92-
9386
stop() {
9487
DOM.removeStyle();
9588
Patcher.unpatchAll();

0 commit comments

Comments
 (0)