714 lines
18 KiB
HTML
714 lines
18 KiB
HTML
|
|
<!DOCTYPE html>
|
||
|
|
<html lang="en">
|
||
|
|
<head>
|
||
|
|
<meta charset="UTF-8">
|
||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
||
|
|
<title>Messages Mod+</title>
|
||
|
|
<style>
|
||
|
|
:root {
|
||
|
|
--bg: #0f1117;
|
||
|
|
--surface: #1a1d27;
|
||
|
|
--surface2: #232733;
|
||
|
|
--border: #2d3140;
|
||
|
|
--text: #e4e6ef;
|
||
|
|
--text2: #8b8fa3;
|
||
|
|
--accent: #6c8cff;
|
||
|
|
--accent-dim: rgba(108, 140, 255, 0.12);
|
||
|
|
--green: #4ade80;
|
||
|
|
--green-dim: rgba(74, 222, 128, 0.12);
|
||
|
|
--red: #f87171;
|
||
|
|
--red-dim: rgba(248, 113, 113, 0.12);
|
||
|
|
--orange: #fb923c;
|
||
|
|
--orange-dim: rgba(251, 146, 60, 0.12);
|
||
|
|
--radius: 12px;
|
||
|
|
}
|
||
|
|
|
||
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||
|
|
|
||
|
|
body {
|
||
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
|
||
|
|
background: var(--bg);
|
||
|
|
color: var(--text);
|
||
|
|
padding: 16px;
|
||
|
|
padding-bottom: 100px;
|
||
|
|
-webkit-user-select: none;
|
||
|
|
user-select: none;
|
||
|
|
}
|
||
|
|
|
||
|
|
.header {
|
||
|
|
text-align: center;
|
||
|
|
padding: 24px 0 20px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.header h1 {
|
||
|
|
font-size: 22px;
|
||
|
|
font-weight: 700;
|
||
|
|
letter-spacing: -0.3px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.header p {
|
||
|
|
color: var(--text2);
|
||
|
|
font-size: 13px;
|
||
|
|
margin-top: 4px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.status-card {
|
||
|
|
background: var(--surface);
|
||
|
|
border: 1px solid var(--border);
|
||
|
|
border-radius: var(--radius);
|
||
|
|
padding: 16px;
|
||
|
|
margin-bottom: 16px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.status-row {
|
||
|
|
display: flex;
|
||
|
|
justify-content: space-between;
|
||
|
|
align-items: center;
|
||
|
|
padding: 6px 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
.status-row:not(:last-child) {
|
||
|
|
border-bottom: 1px solid var(--border);
|
||
|
|
margin-bottom: 4px;
|
||
|
|
padding-bottom: 10px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.status-label {
|
||
|
|
font-size: 13px;
|
||
|
|
color: var(--text2);
|
||
|
|
}
|
||
|
|
|
||
|
|
.status-value {
|
||
|
|
font-size: 13px;
|
||
|
|
font-weight: 600;
|
||
|
|
}
|
||
|
|
|
||
|
|
.badge {
|
||
|
|
display: inline-block;
|
||
|
|
padding: 3px 10px;
|
||
|
|
border-radius: 20px;
|
||
|
|
font-size: 11px;
|
||
|
|
font-weight: 700;
|
||
|
|
text-transform: uppercase;
|
||
|
|
letter-spacing: 0.5px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.badge-modded { background: var(--green-dim); color: var(--green); }
|
||
|
|
.badge-system { background: var(--orange-dim); color: var(--orange); }
|
||
|
|
.badge-unknown { background: var(--surface2); color: var(--text2); }
|
||
|
|
.badge-error { background: var(--red-dim); color: var(--red); }
|
||
|
|
|
||
|
|
.section {
|
||
|
|
margin-bottom: 16px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.section-title {
|
||
|
|
font-size: 12px;
|
||
|
|
font-weight: 700;
|
||
|
|
text-transform: uppercase;
|
||
|
|
letter-spacing: 1px;
|
||
|
|
color: var(--text2);
|
||
|
|
padding: 0 4px;
|
||
|
|
margin-bottom: 8px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.card {
|
||
|
|
background: var(--surface);
|
||
|
|
border: 1px solid var(--border);
|
||
|
|
border-radius: var(--radius);
|
||
|
|
overflow: hidden;
|
||
|
|
}
|
||
|
|
|
||
|
|
.btn {
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
width: 100%;
|
||
|
|
padding: 14px 16px;
|
||
|
|
border: none;
|
||
|
|
background: transparent;
|
||
|
|
color: var(--text);
|
||
|
|
font-size: 14px;
|
||
|
|
font-weight: 500;
|
||
|
|
cursor: pointer;
|
||
|
|
transition: background 0.15s;
|
||
|
|
text-align: left;
|
||
|
|
gap: 12px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.btn:active { background: var(--surface2); }
|
||
|
|
|
||
|
|
.btn:not(:last-child) {
|
||
|
|
border-bottom: 1px solid var(--border);
|
||
|
|
}
|
||
|
|
|
||
|
|
.btn-icon {
|
||
|
|
width: 36px;
|
||
|
|
height: 36px;
|
||
|
|
border-radius: 10px;
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
justify-content: center;
|
||
|
|
font-size: 18px;
|
||
|
|
flex-shrink: 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
.btn-content {
|
||
|
|
flex: 1;
|
||
|
|
min-width: 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
.btn-subtitle {
|
||
|
|
font-size: 11px;
|
||
|
|
color: var(--text2);
|
||
|
|
margin-top: 2px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.btn-chevron {
|
||
|
|
color: var(--text2);
|
||
|
|
font-size: 18px;
|
||
|
|
flex-shrink: 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
.bg-blue { background: var(--accent-dim); }
|
||
|
|
.bg-green { background: var(--green-dim); }
|
||
|
|
.bg-red { background: var(--red-dim); }
|
||
|
|
.bg-orange { background: var(--orange-dim); }
|
||
|
|
|
||
|
|
.primary-btn {
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
justify-content: center;
|
||
|
|
width: 100%;
|
||
|
|
padding: 15px;
|
||
|
|
border: none;
|
||
|
|
border-radius: var(--radius);
|
||
|
|
background: var(--accent);
|
||
|
|
color: #fff;
|
||
|
|
font-size: 15px;
|
||
|
|
font-weight: 600;
|
||
|
|
cursor: pointer;
|
||
|
|
gap: 8px;
|
||
|
|
transition: opacity 0.15s;
|
||
|
|
margin-bottom: 16px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.primary-btn:active { opacity: 0.8; }
|
||
|
|
.primary-btn:disabled {
|
||
|
|
opacity: 0.4;
|
||
|
|
cursor: not-allowed;
|
||
|
|
}
|
||
|
|
|
||
|
|
.primary-btn.danger {
|
||
|
|
background: var(--red);
|
||
|
|
}
|
||
|
|
|
||
|
|
/* Log output area */
|
||
|
|
.log-area {
|
||
|
|
display: none;
|
||
|
|
background: #0a0c10;
|
||
|
|
border: 1px solid var(--border);
|
||
|
|
border-radius: var(--radius);
|
||
|
|
padding: 12px;
|
||
|
|
margin-bottom: 16px;
|
||
|
|
max-height: 300px;
|
||
|
|
overflow-y: auto;
|
||
|
|
font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
|
||
|
|
font-size: 12px;
|
||
|
|
line-height: 1.6;
|
||
|
|
color: var(--text2);
|
||
|
|
white-space: pre-wrap;
|
||
|
|
word-break: break-all;
|
||
|
|
}
|
||
|
|
|
||
|
|
.log-area.visible { display: block; }
|
||
|
|
.log-line-info { color: var(--accent); }
|
||
|
|
.log-line-ok { color: var(--green); }
|
||
|
|
.log-line-err { color: var(--red); }
|
||
|
|
|
||
|
|
/* Backup list modal */
|
||
|
|
.modal-overlay {
|
||
|
|
display: none;
|
||
|
|
position: fixed;
|
||
|
|
inset: 0;
|
||
|
|
background: rgba(0,0,0,0.7);
|
||
|
|
z-index: 100;
|
||
|
|
align-items: flex-end;
|
||
|
|
justify-content: center;
|
||
|
|
}
|
||
|
|
|
||
|
|
.modal-overlay.visible {
|
||
|
|
display: flex;
|
||
|
|
}
|
||
|
|
|
||
|
|
.modal {
|
||
|
|
background: var(--surface);
|
||
|
|
border-radius: 16px 16px 0 0;
|
||
|
|
width: 100%;
|
||
|
|
max-height: 70vh;
|
||
|
|
overflow: hidden;
|
||
|
|
animation: slideUp 0.25s ease-out;
|
||
|
|
}
|
||
|
|
|
||
|
|
@keyframes slideUp {
|
||
|
|
from { transform: translateY(100%); }
|
||
|
|
to { transform: translateY(0); }
|
||
|
|
}
|
||
|
|
|
||
|
|
.modal-header {
|
||
|
|
display: flex;
|
||
|
|
justify-content: space-between;
|
||
|
|
align-items: center;
|
||
|
|
padding: 16px;
|
||
|
|
border-bottom: 1px solid var(--border);
|
||
|
|
}
|
||
|
|
|
||
|
|
.modal-header h3 {
|
||
|
|
font-size: 16px;
|
||
|
|
font-weight: 600;
|
||
|
|
}
|
||
|
|
|
||
|
|
.modal-close {
|
||
|
|
background: var(--surface2);
|
||
|
|
border: none;
|
||
|
|
color: var(--text);
|
||
|
|
width: 30px;
|
||
|
|
height: 30px;
|
||
|
|
border-radius: 50%;
|
||
|
|
font-size: 16px;
|
||
|
|
cursor: pointer;
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
justify-content: center;
|
||
|
|
}
|
||
|
|
|
||
|
|
.modal-body {
|
||
|
|
padding: 8px 0;
|
||
|
|
overflow-y: auto;
|
||
|
|
max-height: calc(70vh - 60px);
|
||
|
|
}
|
||
|
|
|
||
|
|
.backup-item {
|
||
|
|
display: flex;
|
||
|
|
align-items: center;
|
||
|
|
padding: 12px 16px;
|
||
|
|
border-bottom: 1px solid var(--border);
|
||
|
|
gap: 12px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.backup-info {
|
||
|
|
flex: 1;
|
||
|
|
min-width: 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
.backup-name {
|
||
|
|
font-size: 13px;
|
||
|
|
font-weight: 500;
|
||
|
|
white-space: nowrap;
|
||
|
|
overflow: hidden;
|
||
|
|
text-overflow: ellipsis;
|
||
|
|
}
|
||
|
|
|
||
|
|
.backup-size {
|
||
|
|
font-size: 11px;
|
||
|
|
color: var(--text2);
|
||
|
|
margin-top: 2px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.backup-actions {
|
||
|
|
display: flex;
|
||
|
|
gap: 8px;
|
||
|
|
flex-shrink: 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
.backup-actions button {
|
||
|
|
padding: 6px 12px;
|
||
|
|
border: 1px solid var(--border);
|
||
|
|
border-radius: 8px;
|
||
|
|
background: var(--surface2);
|
||
|
|
color: var(--text);
|
||
|
|
font-size: 12px;
|
||
|
|
font-weight: 500;
|
||
|
|
cursor: pointer;
|
||
|
|
}
|
||
|
|
|
||
|
|
.backup-actions button.restore-btn {
|
||
|
|
border-color: var(--accent);
|
||
|
|
color: var(--accent);
|
||
|
|
}
|
||
|
|
|
||
|
|
.backup-actions button.delete-btn {
|
||
|
|
border-color: var(--red);
|
||
|
|
color: var(--red);
|
||
|
|
}
|
||
|
|
|
||
|
|
.empty-state {
|
||
|
|
text-align: center;
|
||
|
|
padding: 32px 16px;
|
||
|
|
color: var(--text2);
|
||
|
|
font-size: 13px;
|
||
|
|
}
|
||
|
|
|
||
|
|
.spinner {
|
||
|
|
display: inline-block;
|
||
|
|
width: 16px;
|
||
|
|
height: 16px;
|
||
|
|
border: 2px solid rgba(255,255,255,0.3);
|
||
|
|
border-top-color: #fff;
|
||
|
|
border-radius: 50%;
|
||
|
|
animation: spin 0.6s linear infinite;
|
||
|
|
}
|
||
|
|
|
||
|
|
@keyframes spin { to { transform: rotate(360deg); } }
|
||
|
|
</style>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
|
||
|
|
<div class="header">
|
||
|
|
<h1>Messages Mod+</h1>
|
||
|
|
<p>Fix RCS on rooted devices</p>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Status Card -->
|
||
|
|
<div class="status-card" id="statusCard">
|
||
|
|
<div class="status-row">
|
||
|
|
<span class="status-label">Messages State</span>
|
||
|
|
<span class="badge badge-unknown" id="stateBadge">Checking...</span>
|
||
|
|
</div>
|
||
|
|
<div class="status-row">
|
||
|
|
<span class="status-label">Package</span>
|
||
|
|
<span class="status-value" id="stateEnabled" style="color:var(--text2)">--</span>
|
||
|
|
</div>
|
||
|
|
<div class="status-row">
|
||
|
|
<span class="status-label">Backups</span>
|
||
|
|
<span class="status-value" id="stateBackups" style="color:var(--text2)">--</span>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Apply / Revert -->
|
||
|
|
<button class="primary-btn" id="applyBtn" onclick="applyMod()" disabled>
|
||
|
|
Apply Mod
|
||
|
|
</button>
|
||
|
|
|
||
|
|
<!-- Log Output -->
|
||
|
|
<div class="log-area" id="logArea"></div>
|
||
|
|
|
||
|
|
<!-- Backup Section -->
|
||
|
|
<div class="section">
|
||
|
|
<div class="section-title">Backup</div>
|
||
|
|
<div class="card">
|
||
|
|
<button class="btn" onclick="runBackup('sms')">
|
||
|
|
<div class="btn-icon bg-blue">💬</div>
|
||
|
|
<div class="btn-content">
|
||
|
|
<div>SMS / MMS Database</div>
|
||
|
|
<div class="btn-subtitle">Backup text and multimedia messages</div>
|
||
|
|
</div>
|
||
|
|
<div class="btn-chevron">›</div>
|
||
|
|
</button>
|
||
|
|
<button class="btn" onclick="runBackup('rcs')">
|
||
|
|
<div class="btn-icon bg-green">⚡</div>
|
||
|
|
<div class="btn-content">
|
||
|
|
<div>RCS Database</div>
|
||
|
|
<div class="btn-subtitle">Backup chat features / RCS messages</div>
|
||
|
|
</div>
|
||
|
|
<div class="btn-chevron">›</div>
|
||
|
|
</button>
|
||
|
|
<button class="btn" onclick="runBackup('attach')">
|
||
|
|
<div class="btn-icon bg-orange">📎</div>
|
||
|
|
<div class="btn-content">
|
||
|
|
<div>Attachments</div>
|
||
|
|
<div class="btn-subtitle">Save photos, videos, and media</div>
|
||
|
|
</div>
|
||
|
|
<div class="btn-chevron">›</div>
|
||
|
|
</button>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Restore Section -->
|
||
|
|
<div class="section">
|
||
|
|
<div class="section-title">Restore</div>
|
||
|
|
<div class="card">
|
||
|
|
<button class="btn" onclick="showBackups('sms')">
|
||
|
|
<div class="btn-icon bg-blue">🔃</div>
|
||
|
|
<div class="btn-content">
|
||
|
|
<div>Restore SMS / MMS</div>
|
||
|
|
<div class="btn-subtitle">Restore from a previous backup</div>
|
||
|
|
</div>
|
||
|
|
<div class="btn-chevron">›</div>
|
||
|
|
</button>
|
||
|
|
<button class="btn" onclick="showBackups('rcs')">
|
||
|
|
<div class="btn-icon bg-green">🔃</div>
|
||
|
|
<div class="btn-content">
|
||
|
|
<div>Restore RCS</div>
|
||
|
|
<div class="btn-subtitle">Restore RCS messages database</div>
|
||
|
|
</div>
|
||
|
|
<div class="btn-chevron">›</div>
|
||
|
|
</button>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Danger Zone -->
|
||
|
|
<div class="section">
|
||
|
|
<div class="section-title">Danger Zone</div>
|
||
|
|
<button class="primary-btn danger" id="uninstallBtn" onclick="uninstallMod()">
|
||
|
|
Revert to Stock
|
||
|
|
</button>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Backup List Modal -->
|
||
|
|
<div class="modal-overlay" id="modalOverlay" onclick="closeModal(event)">
|
||
|
|
<div class="modal">
|
||
|
|
<div class="modal-header">
|
||
|
|
<h3 id="modalTitle">Backups</h3>
|
||
|
|
<button class="modal-close" onclick="closeModal()">×</button>
|
||
|
|
</div>
|
||
|
|
<div class="modal-body" id="modalBody">
|
||
|
|
<div class="empty-state">Loading...</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
const SCRIPT_PATH = '/data/adb/modules/messages_mod_plus/scripts/messages_mod.sh';
|
||
|
|
let busy = false;
|
||
|
|
|
||
|
|
async function exec(cmd) {
|
||
|
|
try {
|
||
|
|
const result = await ksu.exec(cmd);
|
||
|
|
return result;
|
||
|
|
} catch (e) {
|
||
|
|
return { errno: -1, stdout: '', stderr: e.message || 'exec failed' };
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function logClear() {
|
||
|
|
const area = document.getElementById('logArea');
|
||
|
|
area.innerHTML = '';
|
||
|
|
area.classList.add('visible');
|
||
|
|
}
|
||
|
|
|
||
|
|
function logLine(text, type) {
|
||
|
|
const area = document.getElementById('logArea');
|
||
|
|
area.classList.add('visible');
|
||
|
|
const cls = type === 'err' ? 'log-line-err' : type === 'ok' ? 'log-line-ok' : 'log-line-info';
|
||
|
|
area.innerHTML += `<span class="${cls}">${escHtml(text)}</span>\n`;
|
||
|
|
area.scrollTop = area.scrollHeight;
|
||
|
|
}
|
||
|
|
|
||
|
|
function escHtml(s) {
|
||
|
|
return s.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
|
||
|
|
}
|
||
|
|
|
||
|
|
function setBusy(b) {
|
||
|
|
busy = b;
|
||
|
|
document.getElementById('applyBtn').disabled = b;
|
||
|
|
document.getElementById('uninstallBtn').disabled = b;
|
||
|
|
}
|
||
|
|
|
||
|
|
async function refreshStatus() {
|
||
|
|
const r = await exec(`sh ${SCRIPT_PATH} status`);
|
||
|
|
const lines = (r.stdout || '').split('\n');
|
||
|
|
const data = {};
|
||
|
|
lines.forEach(l => {
|
||
|
|
const [k, v] = l.split('=');
|
||
|
|
if (k && v !== undefined) data[k.trim()] = v.trim();
|
||
|
|
});
|
||
|
|
|
||
|
|
const badge = document.getElementById('stateBadge');
|
||
|
|
const state = data.STATE || 'UNKNOWN';
|
||
|
|
|
||
|
|
badge.className = 'badge';
|
||
|
|
if (state === 'MODDED') {
|
||
|
|
badge.classList.add('badge-modded');
|
||
|
|
badge.textContent = 'Modded';
|
||
|
|
document.getElementById('applyBtn').textContent = 'Already Applied';
|
||
|
|
document.getElementById('applyBtn').disabled = true;
|
||
|
|
} else if (state === 'SYSTEM') {
|
||
|
|
badge.classList.add('badge-system');
|
||
|
|
badge.textContent = 'System';
|
||
|
|
document.getElementById('applyBtn').textContent = 'Apply Mod';
|
||
|
|
document.getElementById('applyBtn').disabled = false;
|
||
|
|
} else if (state === 'NOT_INSTALLED') {
|
||
|
|
badge.classList.add('badge-error');
|
||
|
|
badge.textContent = 'Not Installed';
|
||
|
|
document.getElementById('applyBtn').textContent = 'Messages Not Found';
|
||
|
|
document.getElementById('applyBtn').disabled = true;
|
||
|
|
} else {
|
||
|
|
badge.classList.add('badge-unknown');
|
||
|
|
badge.textContent = state;
|
||
|
|
document.getElementById('applyBtn').disabled = false;
|
||
|
|
}
|
||
|
|
|
||
|
|
const enabled = data.ENABLED === 'true';
|
||
|
|
document.getElementById('stateEnabled').textContent = enabled ? 'Enabled' : 'Disabled';
|
||
|
|
document.getElementById('stateEnabled').style.color = enabled ? 'var(--green)' : 'var(--red)';
|
||
|
|
|
||
|
|
const smsB = parseInt(data.SMS_BACKUPS) || 0;
|
||
|
|
const rcsB = parseInt(data.RCS_BACKUPS) || 0;
|
||
|
|
const attB = parseInt(data.ATTACH_BACKUPS) || 0;
|
||
|
|
document.getElementById('stateBackups').textContent = `${smsB} SMS, ${rcsB} RCS, ${attB} Attach`;
|
||
|
|
|
||
|
|
return data;
|
||
|
|
}
|
||
|
|
|
||
|
|
async function applyMod() {
|
||
|
|
if (busy) return;
|
||
|
|
setBusy(true);
|
||
|
|
logClear();
|
||
|
|
logLine('Applying Messages Mod+...', 'info');
|
||
|
|
|
||
|
|
const r = await exec(`sh ${SCRIPT_PATH} apply 2>&1`);
|
||
|
|
const output = r.stdout || '';
|
||
|
|
output.split('\n').forEach(line => {
|
||
|
|
if (!line.trim()) return;
|
||
|
|
if (line.includes('ERROR')) logLine(line, 'err');
|
||
|
|
else if (line.includes('success') || line.includes('Success')) logLine(line, 'ok');
|
||
|
|
else logLine(line, 'info');
|
||
|
|
});
|
||
|
|
|
||
|
|
if (r.stderr) logLine(r.stderr, 'err');
|
||
|
|
|
||
|
|
if (output.includes('RESULT=success') || output.includes('ALREADY_MODDED')) {
|
||
|
|
logLine('Done! Set Messages as default SMS app on your device.', 'ok');
|
||
|
|
} else {
|
||
|
|
logLine('Check output above for errors.', 'err');
|
||
|
|
}
|
||
|
|
|
||
|
|
await refreshStatus();
|
||
|
|
setBusy(false);
|
||
|
|
}
|
||
|
|
|
||
|
|
async function uninstallMod() {
|
||
|
|
if (busy) return;
|
||
|
|
setBusy(true);
|
||
|
|
logClear();
|
||
|
|
logLine('Reverting to stock Messages...', 'info');
|
||
|
|
|
||
|
|
const r = await exec(`sh ${SCRIPT_PATH} uninstall 2>&1`);
|
||
|
|
const output = r.stdout || '';
|
||
|
|
output.split('\n').forEach(line => {
|
||
|
|
if (!line.trim()) return;
|
||
|
|
if (line.includes('ERROR')) logLine(line, 'err');
|
||
|
|
else if (line.includes('success') || line.includes('ALREADY_STOCK')) logLine(line, 'ok');
|
||
|
|
else logLine(line, 'info');
|
||
|
|
});
|
||
|
|
|
||
|
|
if (r.stderr) logLine(r.stderr, 'err');
|
||
|
|
await refreshStatus();
|
||
|
|
setBusy(false);
|
||
|
|
}
|
||
|
|
|
||
|
|
async function runBackup(type) {
|
||
|
|
if (busy) return;
|
||
|
|
setBusy(true);
|
||
|
|
logClear();
|
||
|
|
|
||
|
|
const labels = { sms: 'SMS/MMS', rcs: 'RCS', attach: 'Attachments' };
|
||
|
|
logLine(`Backing up ${labels[type]}...`, 'info');
|
||
|
|
|
||
|
|
const cmd = type === 'attach' ? 'backup-attach' : `backup-${type}`;
|
||
|
|
const r = await exec(`sh ${SCRIPT_PATH} ${cmd} 2>&1`);
|
||
|
|
const output = r.stdout || '';
|
||
|
|
output.split('\n').forEach(line => {
|
||
|
|
if (!line.trim()) return;
|
||
|
|
if (line.includes('ERROR')) logLine(line, 'err');
|
||
|
|
else if (line.includes('BACKUP=')) logLine('Saved: ' + line.split('=')[1], 'ok');
|
||
|
|
else logLine(line, 'info');
|
||
|
|
});
|
||
|
|
|
||
|
|
if (r.stderr) logLine(r.stderr, 'err');
|
||
|
|
await refreshStatus();
|
||
|
|
setBusy(false);
|
||
|
|
}
|
||
|
|
|
||
|
|
async function showBackups(type) {
|
||
|
|
const overlay = document.getElementById('modalOverlay');
|
||
|
|
const title = document.getElementById('modalTitle');
|
||
|
|
const body = document.getElementById('modalBody');
|
||
|
|
|
||
|
|
title.textContent = type === 'sms' ? 'SMS/MMS Backups' : 'RCS Backups';
|
||
|
|
body.innerHTML = '<div class="empty-state">Loading...</div>';
|
||
|
|
overlay.classList.add('visible');
|
||
|
|
|
||
|
|
const r = await exec(`sh ${SCRIPT_PATH} list-backups ${type}`);
|
||
|
|
const lines = (r.stdout || '').trim().split('\n').filter(l => l.includes('|'));
|
||
|
|
|
||
|
|
if (lines.length === 0) {
|
||
|
|
body.innerHTML = '<div class="empty-state">No backups found.<br>Create one from the Backup section above.</div>';
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
let html = '';
|
||
|
|
lines.forEach(line => {
|
||
|
|
const parts = line.split('|');
|
||
|
|
const path = parts[0];
|
||
|
|
const name = parts[1];
|
||
|
|
const size = parts[2];
|
||
|
|
|
||
|
|
html += `
|
||
|
|
<div class="backup-item">
|
||
|
|
<div class="backup-info">
|
||
|
|
<div class="backup-name">${escHtml(name)}</div>
|
||
|
|
<div class="backup-size">${escHtml(size)}</div>
|
||
|
|
</div>
|
||
|
|
<div class="backup-actions">
|
||
|
|
<button class="restore-btn" onclick="restoreBackup('${type}', '${escAttr(path)}')">Restore</button>
|
||
|
|
<button class="delete-btn" onclick="deleteBackup('${escAttr(path)}', this)">Delete</button>
|
||
|
|
</div>
|
||
|
|
</div>`;
|
||
|
|
});
|
||
|
|
|
||
|
|
body.innerHTML = html;
|
||
|
|
}
|
||
|
|
|
||
|
|
function escAttr(s) {
|
||
|
|
return s.replace(/'/g, "\\'").replace(/"/g, '"');
|
||
|
|
}
|
||
|
|
|
||
|
|
async function restoreBackup(type, path) {
|
||
|
|
if (busy) return;
|
||
|
|
closeModal();
|
||
|
|
setBusy(true);
|
||
|
|
logClear();
|
||
|
|
logLine(`Restoring ${type.toUpperCase()} from backup...`, 'info');
|
||
|
|
|
||
|
|
const r = await exec(`sh ${SCRIPT_PATH} restore-${type} '${path}' 2>&1`);
|
||
|
|
const output = r.stdout || '';
|
||
|
|
output.split('\n').forEach(line => {
|
||
|
|
if (!line.trim()) return;
|
||
|
|
if (line.includes('ERROR')) logLine(line, 'err');
|
||
|
|
else if (line.includes('RESTORED=')) logLine('Restored from: ' + line.split('=')[1], 'ok');
|
||
|
|
else logLine(line, 'info');
|
||
|
|
});
|
||
|
|
|
||
|
|
if (r.stderr) logLine(r.stderr, 'err');
|
||
|
|
logLine('Restart Messages or reboot for changes to take effect.', 'info');
|
||
|
|
setBusy(false);
|
||
|
|
}
|
||
|
|
|
||
|
|
async function deleteBackup(path, btnEl) {
|
||
|
|
const r = await exec(`sh ${SCRIPT_PATH} delete-backup '${path}' 2>&1`);
|
||
|
|
if (r.stdout && r.stdout.includes('Deleted')) {
|
||
|
|
const item = btnEl.closest('.backup-item');
|
||
|
|
if (item) item.remove();
|
||
|
|
|
||
|
|
const body = document.getElementById('modalBody');
|
||
|
|
if (!body.querySelector('.backup-item')) {
|
||
|
|
body.innerHTML = '<div class="empty-state">No backups found.</div>';
|
||
|
|
}
|
||
|
|
refreshStatus();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function closeModal(event) {
|
||
|
|
if (event && event.target !== event.currentTarget) return;
|
||
|
|
document.getElementById('modalOverlay').classList.remove('visible');
|
||
|
|
}
|
||
|
|
|
||
|
|
// Init
|
||
|
|
document.addEventListener('DOMContentLoaded', () => {
|
||
|
|
refreshStatus();
|
||
|
|
});
|
||
|
|
</script>
|
||
|
|
</body>
|
||
|
|
</html>
|