Skip to content

DhanNarula/mathmatize-notification-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MathMatize Poll Notifier

A Chrome Extension (Manifest V3) that notifies you when a new question appears in an active MathMatize poll session on mathmatize.com. It uses your existing logged-in session and does not send any data off your device.

Features

  • Desktop notification when the current question changes: title “New MathMatize Question”, body “A new question was posted in your poll session.”
  • Optional sound (short beep) with each notification.
  • Multiple detection strategies: DOM selectors, network (fetch/XHR) responses, and MutationObserver, with fallbacks.
  • Options: toggle notifications/sound, “only when MathMatize tab is not active”, and poll interval (1–10 s).

Load the extension (unpacked)

  1. Open Chrome and go to chrome://extensions/.
  2. Turn Developer mode on (top-right toggle).
  3. Click Load unpacked.
  4. Choose the folder that contains this project (the one with manifest.json).
  5. The extension should appear in your list. Keep the page open on a MathMatize poll/session URL to receive notifications when a new question is pushed.

Files

File Purpose
manifest.json Extension manifest (MV3), permissions, content script matches.
background.js Service worker: creates notifications, optional sound, handles messages.
content.js Runs on MathMatize poll/session pages: fingerprinting, network patch, MutationObserver.
options.html / options.js Options UI: notifications on/off, sound on/off, “only when inactive”, poll interval.
icons/ Extension icons (16, 48, 128). Replace with your own if you like.

How to adapt selectors (if MathMatize changes)

The extension detects the “current question” using several strategies. If the site’s HTML or structure changes, you can adjust behavior by editing content.js.

1. Where to edit

Open content.js and find the SELECTORS object near the top (and the API_QUESTION_KEYS array just below it). All selector and API-key customization is there.

2. What each list does

  • QUESTION_SELECTORS
    Elements that hold the question title or text (e.g. headings, .question-title). The script uses the first matching element with non-empty text.

    • Add or reorder selectors to match the new DOM (e.g. new class names or data-* attributes).
  • QUESTION_ID_SELECTORS
    Elements that have a question id in a data attribute (data-question-id, data-id, etc.).

    • If MathMatize adds new attributes (e.g. data-poll-id), add a selector and read that attribute in the block that builds parts.id.
  • QUESTION_NUMBER_SELECTORS
    Elements that show “Question 1”, “Q2”, etc.

    • Update or add selectors if the question number moves to a new element or class.
  • MAIN_CONTENT_SELECTORS
    The main content container used for:

    • MutationObserver (where we listen for DOM changes), and
    • Fallback when no question-specific element is found (we take a short text snippet from here).
    • If the main area gets a new wrapper (e.g. #poll-root), add it at the beginning of this array so it’s tried first.
  • API_QUESTION_KEYS
    Keys we look for in JSON API responses (from our fetch/XHR patch) to build a fingerprint (e.g. questionId, question_text, title).

    • If MathMatize’s API starts using different field names, add them here (and keep existing ones as fallbacks).

3. Adding a new selector

  1. Choose the right array (question text, id, number, or main content).
  2. Add a string like '.new-class-name' or '[data-new-attr]' at the position you want (earlier = higher priority).
  3. For question id, if you use a new attribute, add it both to QUESTION_ID_SELECTORS and in the block that does el.getAttribute('...') when building parts.id.

4. URL / page matching

Content script runs only on URLs matched in manifest.json under content_scripts[].matches. If MathMatize adds new paths for polls (e.g. /v2/session/...), add a matching pattern there, for example:

"https://www.mathmatize.com/v2/session/*"

Reload the extension after any change.

Debugging (DEBUG flag)

To see detailed logs in the browser console:

  1. Content script (page context): open content.js, set DEBUG = true at the top, save, and reload the extension. Then open a MathMatize poll page, open DevTools → Console, and look for messages starting with [MathMatize Notifier].
  2. Background: open background.js, set DEBUG = true at the top, save, and reload the extension. Then open chrome://extensions/, find the extension, and click “Service worker” to open its console. Logs will appear there.

Remember to set DEBUG = false when you’re done troubleshooting.

Privacy and data

  • The extension only runs on mathmatize.com (and www).
  • It does not send data to any external server.
  • It uses chrome.storage.local for your preferences and the last question fingerprint per tab/session.
  • It does not scrape private content beyond what’s needed to detect a new question (e.g. a short snippet or id for fingerprinting).

Permissions

  • storage: save options and last fingerprint.
  • notifications: show desktop notifications.
  • activeTab / tabs: used so “only notify when MathMatize tab is not active” can check the active tab.
  • host_permissions for https://www.mathmatize.com/* and https://mathmatize.com/*: needed for the content script to run on those pages.

Optional: replace icons

The icons/ folder contains simple placeholder PNGs. To use your own:

  • Provide icon16.png, icon48.png, and icon128.png in the icons/ directory (or update paths in manifest.json).
  • Reload the extension.

About

Desktop notifier for MathMatize live polls. A lightweight Chrome extension that detects when a new question appears in an active session and sends instant notifications so you never miss in-class prompts while working in other tabs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors