39 lines
1.9 KiB
JavaScript
39 lines
1.9 KiB
JavaScript
const fs = require('fs');
|
|
if (fs.existsSync('chats_original_backup.php')) {
|
|
let orig = fs.readFileSync('chats_original_backup.php', 'utf8');
|
|
let curr = fs.readFileSync('chats.php', 'utf8');
|
|
|
|
// 1. Restore Emoji CSS
|
|
let emojiCssMatch = orig.match(/\/\* Emoji Picker \*\/[\s\S]*?\/\* Pin Banner \*\//);
|
|
if(emojiCssMatch) {
|
|
let emojiCss = emojiCssMatch[0].replace('/* Pin Banner */', '').trim();
|
|
curr = curr.replace('/* Custom Context Menu */', emojiCss + '\n\n/* Custom Context Menu */');
|
|
}
|
|
|
|
// 2. Restore Emoji Button in HTML
|
|
let emojiBtn = '<button class="icon-btn" id="btnEmoji" onclick="toggleEmoji()"><i class="mdi mdi-emoticon-outline"></i></button>';
|
|
curr = curr.replace(/<input type="text" id="messageInput" placeholder="Ketik pesan..." onkeypress="handleEnter\(event\)">/, '$& \n ' + emojiBtn);
|
|
|
|
// 3. Restore Emoji Picker HTML
|
|
let emojiHtmlMatch = orig.match(/<!-- Emoji Picker -->[\s\S]*?<!-- Forward Modal -->/);
|
|
if (emojiHtmlMatch) {
|
|
let emojiHtml = emojiHtmlMatch[0].replace('<!-- Forward Modal -->', '').trim();
|
|
curr = curr.replace('<!-- Context Menu -->', emojiHtml + '\n\n<!-- Context Menu -->');
|
|
}
|
|
|
|
// 4. Restore Emoji JS Logic
|
|
let emojiJsMatch = orig.match(/\/\/ ═══ EMOJI PICKER ═══[\s\S]*?\/\/ ═══ VOICE RECORDING ═══/);
|
|
if (emojiJsMatch) {
|
|
let emojiJs = emojiJsMatch[0].replace('// ═══ VOICE RECORDING ═══', '').trim();
|
|
curr = curr.replace('// Initial load', emojiJs + '\n\n// Initial load');
|
|
}
|
|
|
|
// 5. Add call to renderEmojis in ready event
|
|
curr = curr.replace(/loadContacts\(\);\s*setInterval/, "loadContacts();\n renderEmojis('smileys');\n setInterval");
|
|
|
|
fs.writeFileSync('chats.php', curr);
|
|
console.log('Emoji features restored!');
|
|
} else {
|
|
console.log('Backup not found, cannot restore emojis easily.');
|
|
}
|