athan-auto-pause

πŸ•Œ Athan Auto Pause

A production-ready Chrome Extension (Manifest V3) that automatically pauses all audio and video across your browser tabs at Islamic prayer times, based on your location.

✨ Features

πŸ“¦ Installation

Load as Unpacked Extension (Developer Mode)

  1. Download or clone this repository
  2. Open Chrome and navigate to chrome://extensions
  3. Enable Developer mode (toggle in top-right corner)
  4. Click Load unpacked
  5. Select the athan-ext folder
  6. The extension icon should appear in your toolbar

First-Time Setup

  1. Click the extension icon or right-click β†’ Options
  2. Configure your location:
    • Manual City: Enter your city name (uses default coordinates for Makkah if unrecognized)
    • Manual Coordinates: Enter exact latitude/longitude for precise times
    • Geolocation: Let the browser detect your location
  3. Choose your calculation method and madhab
  4. Enable/disable specific prayers as needed
  5. Click Save Settings

πŸ”§ Configuration Options

Location Settings

Option Description
Manual City Enter city and country name
Manual Coordinates Enter latitude, longitude, and timezone
Geolocation Use browser’s location API

Calculation Methods

Method Description
Muslim World League Fajr: 18Β°, Isha: 17Β°
ISNA Fajr: 15Β°, Isha: 15Β°
Egyptian Fajr: 19.5Β°, Isha: 17.5Β°
Umm al-Qura (Makkah) Fajr: 18.5Β°, Isha: 90 min after Maghrib
Karachi Fajr: 18Β°, Isha: 18Β°
Tehran Fajr: 17.7Β°, Isha: 14Β°, Maghrib: 4.5Β°
Jafari Fajr: 16Β°, Isha: 14Β°, Maghrib: 4Β°

Features

πŸ”’ Permissions Explained

Permission Why It’s Needed
alarms Schedule prayer time alarms that persist when the browser sleeps
storage Save your settings and cached prayer times
notifications Show prayer time notifications
scripting Inject pause script into tabs that don’t have the content script
tabs Query and send messages to all open tabs for media pausing
<all_urls> Access any website to pause media (host permission)

No data is collected or transmitted. All calculations are done locally and your settings stay on your device.

πŸ§ͺ Testing

Test Pause Function

  1. Open several tabs with playing media (YouTube, Spotify, etc.)
  2. Go to the extension Options page
  3. Click Test Pause Now
  4. All playing media should pause immediately

Test Alarm Scheduling

  1. Set a prayer time offset to trigger 1 minute from now
  2. Wait for the alarm
  3. A notification should appear and all media should pause

View Scheduled Alarms

Open chrome://extensions, click on β€œService Worker” link for this extension, then check the console for alarm logs.

πŸ“ File Structure

athan-ext/
β”œβ”€β”€ manifest.json        # Extension configuration (MV3)
β”œβ”€β”€ service_worker.js    # Background service worker
β”œβ”€β”€ content_script.js    # Injected into all pages
β”œβ”€β”€ prayertimes.js       # Offline prayer time calculator
β”œβ”€β”€ options.html         # Settings page UI
β”œβ”€β”€ options.js           # Settings page logic
β”œβ”€β”€ icons/
β”‚   β”œβ”€β”€ icon16.png
β”‚   β”œβ”€β”€ icon48.png
β”‚   └── icon128.png
└── README.md

⚠️ Limitations

  1. WebAudio API: Cannot pause audio created via WebAudio API (some games, synthesizers)
  2. Autoplay Policies: Browser may block auto-resume on some sites due to autoplay restrictions
  3. Alarm Precision: Chrome alarms have ~1 minute precision; exact-second timing not guaranteed
  4. Protected Pages: Cannot pause media on chrome://, chrome-extension://, or about: pages
  5. Geolocation: Requires HTTPS context; best used from the options page

πŸͺ Chrome Web Store Policy Compliance

This extension is designed to comply with Chrome Web Store policies:

πŸ”Š Adding Custom Athan Audio

Due to copyright concerns, no athan audio is included by default. To add your own:

  1. Download or create a short audio file (MP3, OGG, or WAV)
  2. Rename it to athan.mp3 and place it in the extension folder
  3. Modify service_worker.js to use an offscreen document for audio playback

Note: Chrome MV3 service workers cannot directly play audio. You would need to implement an offscreen document solution.

🀝 Contributing

Contributions are welcome! Please ensure your code follows the existing style and includes appropriate comments.

πŸ“œ License

MIT License - feel free to use, modify, and distribute.

πŸ™ Credits


Version: 1.0.0
Manifest Version: 3
Minimum Chrome Version: 102+