How jtcheng26/canvas-task-extension works
Main Components
• Browser Extension Entry Points:
– Background Page: Shows up in src/pages/Background (background scripts handling events and extension life cycle).
– Content Scripts: Found in src/pages/Content. These inject UI elements into Canvas pages, handle DOM interactions, and drive the dynamic functionalities.
– Options Page: Provides configuration options for the user; located in src/pages/Options.
• Shared Modules and Libraries:
– UI Components: Under src/pages/Content/modules/components. They include buttons, dropdowns, charts, and task cards. Many of these components are designed in a React/TypeScript paradigm.
– Plugins: Located under src/pages/Content/modules/plugins. These provide adaptability for various LMS platforms (Canvas, Blackboard, Gradescope, Brightspace) with their own loaders and utility functions.
– Contexts, Hooks, and Utilities: Under src/pages/Content/modules/contexts, hooks, and utils, offering state management (via contexts and custom hooks) and helper functions to determine settings, dark mode etc.
– Asset Handling: Under src/assets, which provides images and manifests (manifest-chrome.json and manifest-firefox.json) to support different browsers.
• Testing & Development Infrastructure:
– E2E and integration tests under src/pages/Content/modules/tests.
– Build configuration files (webpack.config.js, package.json, tsconfig.json, etc.) that dictate how the application is bundled and linted (.eslintrc, .prettierrc, etc.).
Relationships and Data Flow
• The Background script acts as a controller for long-running processes and extension events, communicating with the Content scripts.
• Content scripts inject the React-based UI into the Canvas pages, drawing on multiple shared components (for tasks, progress bars, and settings).
• The Plugins act as adapters or layers that detect the specific LMS (e.g., Canvas) using files like detectCanvas.ts and run in their environment, then load assignments or course information from external APIs or page DOM.
• The Options and Popup pages provide user interaction for configuration and quick task views, reading from and writing to persistent settings.
• All components are tied together with state management (contexts and hooks) which synchronize data (assignments, course info, user preferences) across different parts of the extension.
Architectural Patterns and Design Principles
• Component-Based Architecture: The UI is modularized into React components, each handling a specific part of the UI (headers, buttons, charts, etc.).
• Separation of Concerns: There’s a clear split between the background operations, content injection of UI, and user configuration, which allows ease of testing and extension.
• Plugin/Adapter Pattern: Notice the modular “plugins” folders; this pattern provides a way to support different LMSs (Canvas, Blackboard, etc.) through interchangeable loaders and utils.
• Test-Driven Development: The presence of unit and integration tests shows an emphasis on reliability.