Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfa63f5157 | ||
|
|
7c578d2d16 | ||
|
|
41e7a4b81e | ||
|
|
92a7408100 | ||
|
|
c1567aca00 | ||
|
|
40fa9cc9b5 | ||
|
|
cd418f513d | ||
|
|
f68aa305fa | ||
|
|
9edaa687a5 | ||
|
|
b571953f10 | ||
|
|
71ef7fa36f | ||
|
|
73c68cc1e8 | ||
|
|
e11a7aad83 | ||
|
|
cb47d6faac | ||
|
|
106900860a | ||
|
|
b3b4495427 | ||
|
|
79d58f994d | ||
|
|
161f540e40 | ||
|
|
79702cb847 | ||
|
|
2fa4064c7c | ||
|
|
4ef392423a | ||
|
|
e6249ae330 | ||
|
|
51d467fbe7 | ||
|
|
52360ab559 | ||
|
|
c75850da2e | ||
|
|
17aeab9592 | ||
|
|
053c6aaa98 | ||
|
|
57c4b6f204 | ||
|
|
792974bd32 | ||
|
|
631ff4e9d2 | ||
|
|
1537881ebc | ||
|
|
8bcfee341c | ||
|
|
b09e0cea76 | ||
|
|
bf4e7170a6 | ||
|
|
cb2beecc0e | ||
|
|
d6bacef1ec | ||
|
|
9f02bebdea | ||
|
|
0128476c37 | ||
|
|
f7e72ddff3 | ||
|
|
2cf3b71e27 | ||
|
|
8020a24655 | ||
|
|
78570c4088 | ||
|
|
4d7ff1a0e7 | ||
|
|
a072edd6d1 | ||
|
|
d12a7da646 | ||
|
|
c4f379ff1c | ||
|
|
0d29f0116a | ||
|
|
cefad72416 | ||
|
|
544d4aab1a | ||
|
|
5a9c185a48 | ||
|
|
94d9b7a879 | ||
|
|
3c409ea048 | ||
|
|
06d9a4be11 | ||
|
|
b920bf6f61 | ||
|
|
a57d7ac44c | ||
|
|
a0178aa0ab |
+8
-16
@@ -10,19 +10,11 @@ function errMsg(err) {
|
||||
return String((err && err.message) || err);
|
||||
}
|
||||
|
||||
// Build a download URL from PDF bytes. Firefox's background is a real page
|
||||
// (URL.createObjectURL available) and supports blob: URLs in downloads.
|
||||
// Chrome MV3 runs the background as a service worker where URL.createObjectURL
|
||||
// is NOT available, but its downloads API accepts base64 data: URLs.
|
||||
// Firefox rejects data: URLs in browser.downloads.download with
|
||||
// "Access denied for URL data:...", so pick per-browser.
|
||||
function buildDownloadUrl(bytes) {
|
||||
if (typeof URL !== 'undefined' && typeof URL.createObjectURL === 'function') {
|
||||
const blob = new Blob([bytes], { type: 'application/pdf' });
|
||||
return URL.createObjectURL(blob);
|
||||
}
|
||||
// Fallback: Chrome MV3 service worker. PDFs here are small (~150KB), well
|
||||
// within data-URL length limits.
|
||||
// Build a download URL from PDF bytes. Chrome MV3 runs the background as a
|
||||
// service worker, where URL.createObjectURL is NOT available, so we use a
|
||||
// base64 data URL (works in both Firefox and Chrome). PDFs here are small
|
||||
// (~150KB), well within data-URL length limits.
|
||||
function pdfDataUrl(bytes) {
|
||||
let binary = '';
|
||||
const chunk = 0x8000;
|
||||
for (let i = 0; i < bytes.length; i += chunk) {
|
||||
@@ -53,9 +45,9 @@ function formatPeriod(period) {
|
||||
|
||||
async function generatePdf(data) {
|
||||
const bytes = await ISMIStools.buildStudyLoadPdf(data);
|
||||
// Firefox accepts blob: object URLs; Chrome MV3 service worker has no
|
||||
// URL.createObjectURL, so it falls back to a base64 data: URL there.
|
||||
const url = buildDownloadUrl(bytes);
|
||||
// Chrome MV3 background is a service worker (no URL.createObjectURL), so we
|
||||
// use a base64 data URL that works in both browsers.
|
||||
const url = pdfDataUrl(bytes);
|
||||
const header = data.header || {};
|
||||
const year = parseInt(data.year, 10);
|
||||
const period = formatPeriod(data.period || header.semester || '');
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "ISMIS Helper",
|
||||
"version": "1.3.0",
|
||||
"version": "1.2.0",
|
||||
"description": "Auto-login, auto-accept privacy policy, and Study Load PDF for the USC ISMIS portal.",
|
||||
"permissions": ["storage", "downloads"],
|
||||
"host_permissions": ["https://ismis.usc.edu.ph/*"],
|
||||
|
||||
Reference in New Issue
Block a user