SACC / javascript /select_course.js
cacode's picture
Deploy updated SCU course catcher
e28c9e4 verified
raw
history blame contribute delete
620 Bytes
const target = arguments[0];
const iframe = document.getElementById("ifra");
if (!iframe) {
return "no";
}
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
if (!iframeDoc) {
return "no";
}
const rows = iframeDoc.querySelectorAll("#xirxkxkbody tr");
for (const row of rows) {
const cells = row.querySelectorAll("td");
if (cells.length < 3) {
continue;
}
const rowText = cells[2].innerText.trim();
if (!rowText.includes(target)) {
continue;
}
const picker = cells[0].querySelector("input");
if (picker) {
picker.click();
return "yes";
}
}
return "no";