1
- import React , { Suspense } from 'react' ;
1
+ import React , { Suspense , useEffect } from 'react' ;
2
2
import { render } from 'react-dom' ;
3
3
import { Provider } from 'react-redux' ;
4
4
import { Router } from 'react-router-dom' ;
@@ -21,6 +21,8 @@ const initialState = window.__INITIAL_STATE__;
21
21
22
22
const store = configureStore ( initialState ) ;
23
23
24
+ const DONATE_LOGO_IMAGE_URL = 'https://donorbox.org/images/white_logo.svg' ;
25
+
24
26
if (
25
27
window . location . href . indexOf ( 'full' ) === - 1 &&
26
28
window . location . href . indexOf ( 'embed' ) === - 1
56
58
'background: #f1678e; color: #fff; text-decoration: none; font-family: Verdana, sans-serif; display: flex; gap: 8px; width: fit-content; font-size: 16px; border-radius: 0 0 5px 5px; line-height: 24px; position: fixed; top: 50%; transform-origin: center; z-index: 9999; overflow: hidden; padding: 8px 22px 8px 18px; right: 20px; left: auto; transform: translate(50%, -50%) rotate(90deg)'
57
59
) ;
58
60
buttonScript . setAttribute ( 'data-button-cta' , 'Donate' ) ;
59
- buttonScript . setAttribute (
60
- 'data-img-src' ,
61
- 'https://donorbox.org/images/white_logo.svg'
62
- ) ;
61
+ buttonScript . setAttribute ( 'data-img-src' , DONATE_LOGO_IMAGE_URL ) ;
63
62
64
63
document . body . appendChild ( buttonScript ) ;
65
64
}
66
65
67
66
const App = ( ) => {
68
67
const { t } = useTranslation ( ) ;
69
68
70
- setTimeout ( ( ) => {
71
- const donateButton = document . getElementsByClassName (
72
- 'dbox-donation-button'
73
- ) [ 0 ] ;
74
-
75
- if ( donateButton ) {
76
- const donateLogoImage = document . createElement ( 'img' ) ;
77
- donateLogoImage . src = 'https://donorbox.org/images/white_logo.svg' ;
78
-
79
- donateButton . text = t ( 'About.Donate' ) ;
80
- donateButton . prepend ( donateLogoImage ) ;
81
- }
82
- } , 0 ) ;
69
+ useEffect ( ( ) => {
70
+ setTimeout ( ( ) => {
71
+ const donateButton = document . getElementsByClassName (
72
+ 'dbox-donation-button'
73
+ ) [ 0 ] ;
74
+
75
+ if ( donateButton ) {
76
+ const donateLogoImage = document . createElement ( 'img' ) ;
77
+ donateLogoImage . src = DONATE_LOGO_IMAGE_URL ;
78
+
79
+ donateButton . text = t ( 'About.Donate' ) ;
80
+ donateButton . prepend ( donateLogoImage ) ;
81
+ }
82
+ } , 500 ) ;
83
+ } , [ t ] ) ;
83
84
84
85
return (
85
86
< div >
0 commit comments