Update TGBeta.ps1

This commit is contained in:
2025-01-07 02:10:27 -05:00
parent 09a9cc4a37
commit c34ae64236

View File

@@ -916,13 +916,14 @@ function GetHtmlContent {
const tweaks = []; const tweaks = [];
const tweakCheckboxes = document.querySelectorAll('#tweaksTab input[type="checkbox"]:not(#selectAllTweaksCheckbox)'); const tweakCheckboxes = document.querySelectorAll('#tweaksTab input[type="checkbox"]:not(#selectAllTweaksCheckbox)');
// Collect the selected tweaks // Collect selected tweaks
tweakCheckboxes.forEach((checkbox) => { tweakCheckboxes.forEach((checkbox) => {
if (checkbox.checked) { if (checkbox.checked) {
tweaks.push(checkbox.id); // Use checkbox IDs as identifiers tweaks.push(checkbox.id); // Use checkbox IDs as identifiers
} }
}); });
// Check if no tweaks are selected
if (tweaks.length === 0) { if (tweaks.length === 0) {
appendLog("No tweaks selected. Please select at least one tweak to run.", "red"); appendLog("No tweaks selected. Please select at least one tweak to run.", "red");
return; return;
@@ -930,31 +931,34 @@ function GetHtmlContent {
appendLog("Running selected tweaks...", "yellow"); appendLog("Running selected tweaks...", "yellow");
// Prepare the payload // Prepare payload
const payload = { tweaks }; const payload = JSON.stringify({ tweaks });
// Make the request using fetch with a promise-based approach // Use fetch to call the backend
fetch('/runTweaks', { fetch('/runTweaks', {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: {
body: JSON.stringify(payload), 'Content-Type': 'application/json',
},
body: payload,
}) })
.then((response) => { .then((response) => {
if (!response.ok) { if (!response.ok) {
throw new Error('Failed to run selected tweaks. Please try again.'); throw new Error(`Failed to run tweaks. Status: ${response.status}`);
} }
return response.text(); // Extract text response return response.text(); // Parse response as text
}) })
.then((result) => { .then((result) => {
appendLog(result, "green"); appendLog(result, "green");
}) })
.catch((error) => { .catch((error) => {
appendLog(`Error: ${error.message}`, "red"); appendLog(`Error running tweaks: ${error.message}`, "red");
}); });
} }
function appendLog(message, color = "white") { function appendLog(message, color = "white") {
const log = document.createElement('p'); const log = document.createElement('p');
log.style.color = color; log.style.color = color;