Skip to content

Scheduled Downloads#2

Open
skapoor68 wants to merge 1 commit into
jasp-nerd:mainfrom
skapoor68:scheduled-downloads
Open

Scheduled Downloads#2
skapoor68 wants to merge 1 commit into
jasp-nerd:mainfrom
skapoor68:scheduled-downloads

Conversation

@skapoor68

Copy link
Copy Markdown

This adds the ability for users to schedule recurring downloads of their Canvas courses. This is helpful for students who want their course materials automatically kept up to date locally, and for protecting against unplanned Canvas outages.

AI summary attached:

What's new

A Scheduled Downloads section in Settings lets users:

  • Enable a recurring download on a fixed interval (12 h, 24 h, 48 h, or 7 days)
  • Select which courses to include from a live list of their active Canvas enrollments
  • See the last run timestamp and next scheduled run time

A small nudge link in the popup ("or schedule a recurring download") links directly to Settings for discoverability.


Expected behavior

  • When Canvas is open: the alarm fires and the download starts immediately in the active Canvas tab.
  • When Canvas is closed or CPU is asleep: the pending run is saved to local storage. The next time the user opens any Canvas page, the run executes automatically before they interact with anything.
  • Alarm durability: chrome.alarms survive browser restarts — if Chrome was closed when an alarm fired, it fires shortly after relaunch.
  • Two tabs open simultaneously: the pending run is cleared before execution begins, so only one tab picks it up.
  • All existing settings apply as-are (conflictAction, zipMode, contentTypes, folderPrefix, incrementalMode, throttle). No overrides.
  • Disabling the toggle immediately unregisters the alarm and clears the config without requiring a Save. Enabling requires Save to register the alarm.
  • Unenrolled/inaccessible courses are skipped gracefully (existing 401/403 handling in downloadCourse) and counted as failed without aborting the run.

New storage keys

Key Store Purpose
scheduleConfig sync Enabled state, interval, selected course IDs and names — roams with Chrome profile
canvasDomain local Written once on first Canvas page load so the background service worker can locate an open Canvas tab
pendingRun local Deferred run waiting to execute; cleared immediately on pickup
lastScheduledRun local Timestamp and result of the most recent run; displayed in Settings

New permissions

  • alarms — fires the recurring schedule
  • tabs — lets the background service worker find an open Canvas tab to deliver the download to; required for non-instructure.com Canvas domains where host permissions don't cover tab URL access

Files changed

File Change
manifest.json Added alarms, tabs permissions
background.js Alarm registration/unregistration, handleScheduleAlarm, findOpenCanvasTab, new message handlers
content.js persistCanvasDomain, checkPendingDownload, runScheduledDownload, TRIGGER_SCHEDULED_DOWNLOAD message handler
options.js Schedule UI: loadScheduleConfig, saveScheduleConfig, renderCoursePickerForSchedule, onScheduleToggle
options.html Scheduled Downloads card with toggle, interval select, course picker, status lines
popup.html / popup.js "Schedule a recurring download" nudge link
README.md / PRIVACY.md Documented new feature and permissions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant