Added numerica script. Unfortunately, two parts

This commit is contained in:
2026-01-15 21:04:36 -08:00
parent 85bc5e7ebf
commit aed14e2ba7
2 changed files with 102 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
javascript:(async function() {
var wait = (ms) => new Promise(r => setTimeout(r, ms));
var name = "Statement";
if (window.location.hash.includes("Account=")) {
name = window.location.hash.split("Account=")[1];
} else {
name = prompt("Enter Account Name (Valley, SHC, BSBS, Ascott):") || "Statement";
}
var links = Array.from(document.querySelectorAll("a.DocLink"));
if (links.length === 0) {
alert("No statements found. Please wait for the list to load.");
return;
}
var count = 0;
var months = {'JAN':'01','FEB':'02','MAR':'03','APR':'04','MAY':'05','JUN':'06','JUL':'07','AUG':'08','SEP':'09','OCT':'10','NOV':'11','DEC':'12'};
console.log(">>> Starting Download Job for: " + name);
for (const link of links) {
var textDiv = link.querySelector(".fiftydoc");
var rawText = textDiv ? textDiv.innerText.trim() : link.innerText.trim();
var m = rawText.match(/([A-Za-z]{3})\s+(\d{4})/);
if (!m) continue;
var mm = months[m[1].toUpperCase()];
if (!mm) continue;
var filename = "Numerica - " + name + " - " + m[2] + "-" + mm + ".pdf";
console.log("Processing: " + filename);
try {
var resp = await fetch(link.href);
var text = await resp.text();
var parser = new DOMParser();
var doc = parser.parseFromString(text, "text/html");
var saveLink = doc.querySelector("#SaveAnchor");
if (saveLink && saveLink.href) {
var pdfUrl = saveLink.getAttribute("href");
if (!pdfUrl.startsWith("http")) {
pdfUrl = saveLink.href;
}
var pdfResp = await fetch(pdfUrl);
var pdfBlob = await pdfResp.blob();
var blobUrl = window.URL.createObjectURL(pdfBlob);
var a = document.createElement('a');
a.style.display = 'none';
a.href = blobUrl;
a.download = filename;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(blobUrl);
document.body.removeChild(a);
count++;
console.log(" -> Downloaded");
} else {
console.warn(" -> Failed: Could not find #SaveAnchor in wrapper.");
}
await wait(1500);
} catch (e) {
console.error("Failed " + filename, e);
}
}
alert("Batch Complete! Downloaded " + count + " files.");
})();