Skip to content

Instantly share code, notes, and snippets.

@MaxySpark
Created February 2, 2025 19:40
Show Gist options
  • Save MaxySpark/2d902b18bb3a9b0c9aaf3e623ab3a10b to your computer and use it in GitHub Desktop.
Save MaxySpark/2d902b18bb3a9b0c9aaf3e623ab3a10b to your computer and use it in GitHub Desktop.
UGC Net Score Calculate
function extractFormOptionsData() {
let rows = document.querySelectorAll('.form-options-item');
let data = {};
rows.forEach(row => {
let cells = row.getElementsByTagName('td');
if (cells.length >= 2) {
let key = cells[0].textContent.trim();
let value = cells[1].textContent.trim().replace(/"/g, '').trim();
data[key] = parseInt(value, 10);
}
});
return data;
}
extractFormOptionsData();
function extractAllQuestionData() {
let tables = document.querySelectorAll('.menu-tbl');
let data = {};
tables.forEach(table => {
let rows = table.getElementsByTagName('tr');
let questionID = null;
let chosenOption = null;
for (let row of rows) {
let keyCell = row.cells[0]?.textContent.trim();
let valueCell = row.cells[1]?.textContent.trim();
if (keyCell === 'Question ID :') {
questionID = valueCell;
} else if (keyCell === 'Chosen Option :') {
chosenOption = valueCell;
}
}
if (questionID && chosenOption) {
data[questionID] = parseInt(chosenOption, 10);
}
});
return data;
}
extractAllQuestionData();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment