Skip to content

Commit 5e65e76

Browse files
authored
Add files via upload
Fixed Image Selection Command `setImage` and fixed reinjection command ``reinject` to also update the image
1 parent 79a7c69 commit 5e65e76

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

inject.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function updateScriptFiles(base64String) {
4444
let fileContent = fs.readFileSync(filePath, 'utf-8');
4545

4646
// Find and replace `const imageBase64Background = null;`
47-
const searchPattern = /const imageBase64Background = null;/g;
47+
const searchPattern = /const imageBase64Background = /g;
4848
if (searchPattern.test(fileContent)) {
4949
fileContent = fileContent.replace(searchPattern, `const imageBase64Background = "${base64String}";`);
5050
fs.writeFileSync(filePath, fileContent, 'utf-8');
@@ -306,8 +306,14 @@ rl.on('line', (input) => {
306306
const trimmedInput = input.trim();
307307

308308
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());
309312
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
311317
} else if (trimmedInput.startsWith('setImage')) {
312318
const filePath = trimmedInput.split(' ')[1]; // Get the file path after the "setImage" command
313319

scripts/blu-theme/main.js

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)