@@ -44,7 +44,7 @@ function updateScriptFiles(base64String) {
44
44
let fileContent = fs . readFileSync ( filePath , 'utf-8' ) ;
45
45
46
46
// Find and replace `const imageBase64Background = null;`
47
- const searchPattern = / c o n s t i m a g e B a s e 6 4 B a c k g r o u n d = n u l l ; / g;
47
+ const searchPattern = / c o n s t i m a g e B a s e 6 4 B a c k g r o u n d = / g;
48
48
if ( searchPattern . test ( fileContent ) ) {
49
49
fileContent = fileContent . replace ( searchPattern , `const imageBase64Background = "${ base64String } ";` ) ;
50
50
fs . writeFileSync ( filePath , fileContent , 'utf-8' ) ;
@@ -306,8 +306,14 @@ rl.on('line', (input) => {
306
306
const trimmedInput = input . trim ( ) ;
307
307
308
308
if ( trimmedInput . startsWith ( 'reinject' ) ) {
309
+ // Run the function to update the scripts
310
+ console . log ( "Updating background" ) ;
311
+ updateScriptFiles ( fs . readFileSync ( "background.txt" , 'utf-8' ) . trim ( ) ) ;
309
312
console . log ( 'Reinjecting scripts...' ) ;
310
- injectScriptsIntoAllPages ( ) ; // Assuming this function is defined elsewhere
313
+
314
+ setTimeout ( async ( ) => {
315
+ await injectScriptsIntoAllPages ( ) ;
316
+ } , 2000 ) ; // Delay to ensure pages are fully loaded
311
317
} else if ( trimmedInput . startsWith ( 'setImage' ) ) {
312
318
const filePath = trimmedInput . split ( ' ' ) [ 1 ] ; // Get the file path after the "setImage" command
313
319
0 commit comments