build-extension / build (push) Successful in 37s
Squash merge of feat/ismis-helper into prod.
4.2 KiB
4.2 KiB
ISMIS Helper — Agent Guide
Guidance for AI coding agents and contributors working in this repository.
What this is
A Firefox/Chrome MV3 extension that automates the USC ISMIS student portal
(ismis.usc.edu.ph): auto-login, privacy-policy auto-accept, and a Study Load
PDF export that visually matches the official document (bundled Segoe UI
fonts, USC logo, course table, units total).
No build step is required for the source itself; scripts/build.js only packages
the two browser variants into dist/.
Commands
npm install # dev deps (only needed for tests)
npm test # run the test suite (node --test)
node scripts/build.js all # build both browser zips -> dist/
node scripts/build.js firefox # build just firefox
node scripts/build.js chrome # build just chrome
node scripts/build.js all --version 1.3.0 # versioned zips
npm run build # shorthand for `node scripts/build.js all`
Never edit anything under dist/ — it is generated and gitignored.
Repo layout
manifest.json— Firefox manifest (the single source of truth). The Chrome manifest is derived at build time.background.js— message handler; builds the PDF viapdf.jsand downloads it. Also has the cross-browserbrowser.*/chrome.*alias shim at the top.content.js— runs on ismis.usc.edu.ph: auto-login, privacy modal auto-accept, scrapes the study load, injects the on-page Download PDF button.parsers.js— pure HTML-scraping helpers (study load table, profile page, offered courses, filtering/summing).pdf.js— builds the PDF; exportsbuildStudyLoadPdfplus formatting helpers (compactProgram,formatSchedule,formatFullName,formatTeacher,deriveDateRange,truncateToWidth).popup.html/popup.js/popup.css— settings UI (profiles, master toggle, PDF settings like truncation and Year Level).libs/— vendoredpdf-lib.min.jsandfontkit.min.js(needed to embed the custom Segoe UI fonts).assets/— the transparent PNG logo andfonts/Segoe-UI*.ttf.icons/— 16/32/48/128 extension icons.scripts/build.js— zero-dependency packaging script for both browsers..gitea/workflows/build.yml— Gitea Actions: builds + tests on push, creates a Gitea Release with both zips when av*tag is pushed.test/—node --testsuite (pdf.test.js,parsers.test.js).
Build model (Firefox vs Chrome)
- The root is the Firefox source:
manifest.jsonusesbackground.scripts(multiple files) andbrowser.*APIs. - The Chrome build derives a manifest with
"background": { "service_worker": "background.chrome.js" }and assembles that single worker by concatenating, in order:libs/fontkit.min.js→libs/pdf-lib.min.js→pdf.js→background.js. - The cross-browser shim (top of
background.js,content.js,popup.js) aliasesbrowsertochromewhen the former is absent. It is a no-op in Firefox. scripts/build.jsexcludestest/,docs/,scripts/,dist/, and.gitfrom the packaged output.
Conventions & constraints
- Plain ES5+ JavaScript. No framework, no bundler, no build step for the source.
- Use Promise-based
browser.*APIs (Chrome MV3 supportsbrowser.*; the shim covers builds that only exposechrome.*). - Login profiles are stored plaintext in
browser.storage.local. At most one profile is enabled at a time; a masterenabledtoggle disables all behavior. - The on-page Download PDF button must never touch another window's DOM; it
sends a message to the background which downloads via
browser.downloads.download({ saveAs: true })(blob → object URL). - If you change
pdf.jslayout constants, verify against the reference PDF (/Users/adrianbonpin/Downloads/BSIT - Y3S1 - Study Load.pdf) and re-check the position measurements, since offsets can be font-metric dependent. - Keep
docs/anddist/out of git (they are ignored).
Workflow
- Run
npm testbefore and after changes. - Build (
npm run build) to make sure both variants assemble. - Manually load
dist/firefoxin Firefox (about:debugging) anddist/chromein Chrome (chrome://extensions) to verify PDF generation.