Added numerica script. Unfortunately, two parts
This commit is contained in:
29
numerica_download1_bookmarklet.js
Normal file
29
numerica_download1_bookmarklet.js
Normal file
@@ -0,0 +1,29 @@
|
||||
javascript:(function(){
|
||||
var name = "Statement";
|
||||
var n = document.querySelector('select.member_number option:checked');
|
||||
var c = document.querySelector('.jcf-select-text');
|
||||
var t = (n ? n.innerText : (c ? c.innerText : "")) || "";
|
||||
t = t.toUpperCase();
|
||||
if(t.includes("VALLEY")) name = "Valley";
|
||||
else if(t.includes("SHC")) name = "SHC";
|
||||
else if(t.includes("ASCOTT")) name = "Ascott";
|
||||
else if(t.includes("BSBS")||t.includes("HTP")) name = "BSBS";
|
||||
|
||||
var btn = document.querySelector('#show_sso');
|
||||
var div = document.querySelector('.open_common_sso');
|
||||
var fr = document.querySelector('#common_sso_iframe iframe');
|
||||
|
||||
var url = null;
|
||||
if(btn && btn.getAttribute('url')) url = btn.getAttribute('url');
|
||||
else if(div && div.getAttribute('sso_url')) url = div.getAttribute('sso_url');
|
||||
else if(fr && fr.src) url = fr.src;
|
||||
|
||||
if(!url){
|
||||
alert("Could not find the statement button. Please select an account first.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(url.startsWith("/")) url = window.location.origin + url;
|
||||
|
||||
window.open(url + "#Account=" + name, '_blank');
|
||||
})();
|
||||
73
numerica_download2_bookmarklet.js
Normal file
73
numerica_download2_bookmarklet.js
Normal 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.");
|
||||
})();
|
||||
Reference in New Issue
Block a user