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