@@ -20,67 +20,61 @@ const config = {
20
20
}
21
21
}
22
22
23
+ // common\Api.js
23
24
const Api = new BdApi ( config . info . name ) ;
24
-
25
25
const UI = Api . UI ;
26
26
const DOM = Api . DOM ;
27
27
const React = Api . React ;
28
28
const Patcher = Api . Patcher ;
29
+ const Logger = Api . Logger ;
30
+ const Webpack = Api . Webpack ;
29
31
30
- const getModule = Api . Webpack . getModule ;
32
+ // common\Webpack.js
33
+ const getModule = Webpack . getModule ;
31
34
35
+ // @Modules \RenderLinkComponent
32
36
const RenderLinkComponent = getModule ( m => m . type ?. toString ?. ( ) . includes ( "MASKED_LINK" ) , { searchExports : false } ) ;
33
37
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
34
44
function copy ( data ) {
35
45
DiscordNative . clipboard . copy ( data ) ;
36
46
}
37
47
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
53
49
function showToast ( content , type ) {
54
50
UI . showToast ( `[${ config . info . name } ] ${ content } ` , { timeout : 5000 , type } ) ;
55
51
}
56
-
57
52
const Toast = {
58
53
success ( content ) { showToast ( content , "success" ) ; } ,
59
54
info ( content ) { showToast ( content , "info" ) ; } ,
60
55
warning ( content ) { showToast ( content , "warning" ) ; } ,
61
56
error ( content ) { showToast ( content , "error" ) ; }
62
57
} ;
63
58
59
+ // src\CopyImageLink\components\CopyButtonComponent.jsx
64
60
const CopyButtonComponent = ( { href } ) => {
65
61
return (
66
62
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" ) )
75
69
) ;
76
70
} ;
77
71
72
+ // src\CopyImageLink\index.jsx
78
73
class CopyImageLink {
79
74
start ( ) {
80
75
try {
81
-
82
76
DOM . addStyle ( css ) ;
83
- if ( ! RenderLinkComponent ) return Logger . patch ( "RenderLinkComponent" ) ;
77
+ if ( ! RenderLinkComponent ) return Logger . patchError ( "RenderLinkComponent" ) ;
84
78
Patcher . after ( RenderLinkComponent , "type" , ( _ , [ { className, href } ] , returnValue ) => {
85
79
if ( ! returnValue || ! className ?. startsWith ( "downloadLink" ) || ! href ) return ;
86
80
return [ returnValue , React . createElement ( CopyButtonComponent , { href : href , } ) ] ;
@@ -89,7 +83,6 @@ class CopyImageLink {
89
83
Logger . error ( e ) ;
90
84
}
91
85
}
92
-
93
86
stop ( ) {
94
87
DOM . removeStyle ( ) ;
95
88
Patcher . unpatchAll ( ) ;
0 commit comments