1- import React , { Suspense } from 'react' ;
1+ import React , { Suspense , useEffect } from 'react' ;
22import { render } from 'react-dom' ;
3- import { Provider } from 'react-redux' ;
3+ import { Provider , useSelector } from 'react-redux' ;
44import { Router } from 'react-router-dom' ;
55
66import { useTranslation } from 'react-i18next' ;
@@ -21,6 +21,8 @@ const initialState = window.__INITIAL_STATE__;
2121
2222const store = configureStore ( initialState ) ;
2323
24+ const DONATE_LOGO_IMAGE_URL = 'https://donorbox.org/images/white_logo.svg' ;
25+
2426if (
2527 window . location . href . indexOf ( 'full' ) === - 1 &&
2628 window . location . href . indexOf ( 'embed' ) === - 1
5658 '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)'
5759 ) ;
5860 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 ) ;
6362
6463 document . body . appendChild ( buttonScript ) ;
6564}
6665
6766const App = ( ) => {
6867 const { t } = useTranslation ( ) ;
69-
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 ) ;
68+ const language = useSelector ( ( state ) => state . preferences . language ) ;
69+
70+ useEffect ( ( ) => {
71+ setTimeout ( ( ) => {
72+ const donateButton = document . getElementsByClassName (
73+ 'dbox-donation-button'
74+ ) [ 0 ] ;
75+
76+ if ( donateButton ) {
77+ const donateLogoImage = document . createElement ( 'img' ) ;
78+ donateLogoImage . src = DONATE_LOGO_IMAGE_URL ;
79+
80+ donateButton . text = t ( 'About.Donate' ) ;
81+ donateButton . prepend ( donateLogoImage ) ;
82+ }
83+ } , 500 ) ;
84+ } , [ language ] ) ;
8385
8486 return (
8587 < div >
0 commit comments