Skip to main content

Functions

getNextOccurrenceFrom(timeStr, fromTimestamp) ⇒ number | null

Calculates the next occurrence of a given time string strictly after a specified timestamp. Handles time strings in “HH:MM” format or ISO strings by extracting “HH:MM”. If the calculated time on the same day as fromTimestamp is in the past or same as fromTimestamp, it advances to the next day.

getNextWeeklyOccurrenceFrom(timeStr, daysOfWeek, fromTimestamp) ⇒ number | null

Calculates the next weekly occurrence of a given time on specified days of the week, strictly after a specified timestamp. Handles time strings in “HH:MM” format or ISO strings by extracting “HH:MM”. It finds the earliest possible time across all specified daysOfWeek that is after fromTimestamp.

pruneClearedMissedAlarms(clearedList) ⇒ Array.<object>

Utility to prune cleared missed alarms older than a defined period (currently 30 days). Filters an array of cleared missed alarm objects, removing entries whose clearedAt timestamp is older than the pruning threshold relative to the current time.

checkMissedAlarmsOnStartup()

Checks for schedules that should have run while the extension was inactive (e.g., browser closed). If missed alarms are enabled and found, it stores them in chrome.storage.local and displays a notification to the user. For recurring schedules, it identifies the latest missed instance.

createContextMenus()

Creates and configures context menus for the extension. It sets up the following:
  • A parent menu “Add current page to Chronotab” (context: page) with options to: “Create New Schedule…”
  • Add to existing schedules (if any are present).
  • A parent menu “Run Chronotab schedule now” (contexts: action, browser_action, page) with options to: Run existing schedules (if any are present).
  • Shows “No schedules configured” (disabled) if none exist.
This function first removes all existing context menus to ensure a clean setup before recreating them. Schedule data is fetched from chrome.storage.sync to populate the menu items.

Typedefs

Alarm : object

Represents a Chrome alarm object used by the extension.

MessageRequest : object

Defines the structure of messages sent to the background script for various actions.

SendResponse : function

A callback function used to send a response to a message sender in Chrome extensions.

ContextMenuOnClickData : object

Provides information about the context menu item that was clicked.

Tab : object

Represents a browser tab in Chrome.

OnInstalledDetails : object

Contains details about the installation or update event of the extension.

StorageChange : object

Describes the change in a single storage item, as provided by chrome.storage.onChanged.

StorageChanges : object.<string, StorageChange>

An object where each key is the name of a storage item that changed, and the value is a StorageChange object.

getNextOccurrenceFrom(timeStr, fromTimestamp) ⇒ number | null

Calculates the next occurrence of a given time string strictly after a specified timestamp. Handles time strings in “HH:MM” format or ISO strings by extracting “HH:MM”. If the calculated time on the same day as fromTimestamp is in the past or same as fromTimestamp, it advances to the next day. Kind: global function
Returns: number | null - The timestamp of the next occurrence, or null if the time string is invalid or calculation fails.

getNextWeeklyOccurrenceFrom(timeStr, daysOfWeek, fromTimestamp) ⇒ number | null

Calculates the next weekly occurrence of a given time on specified days of the week, strictly after a specified timestamp. Handles time strings in “HH:MM” format or ISO strings by extracting “HH:MM”. It finds the earliest possible time across all specified daysOfWeek that is after fromTimestamp. Kind: global function
Returns: number | null - The timestamp of the earliest next weekly occurrence, or null if inputs are invalid or no valid occurrence is found.

pruneClearedMissedAlarms(clearedList) ⇒ Array.<object>

Utility to prune cleared missed alarms older than a defined period (currently 30 days). Filters an array of cleared missed alarm objects, removing entries whose clearedAt timestamp is older than the pruning threshold relative to the current time. Kind: global function
Returns: Array.<object> - A new array containing only the cleared missed alarm entries that are within the 30-day retention period.

checkMissedAlarmsOnStartup()

Checks for schedules that should have run while the extension was inactive (e.g., browser closed). If missed alarms are enabled and found, it stores them in chrome.storage.local and displays a notification to the user. For recurring schedules, it identifies the latest missed instance. Kind: global function

createContextMenus()

Creates and configures context menus for the extension. It sets up the following:
  • A parent menu “Add current page to Chronotab” (context: page) with options to:
    • “Create New Schedule…”
    • Add to existing schedules (if any are present).
  • A parent menu “Run Chronotab schedule now” (contexts: action, browser_action, page) with options to:
    • Run existing schedules (if any are present).
    • Shows “No schedules configured” (disabled) if none exist.
This function first removes all existing context menus to ensure a clean setup before recreating them. Schedule data is fetched from chrome.storage.sync to populate the menu items. Kind: global function

Alarm : object

Represents a Chrome alarm object used by the extension. Kind: global typedef
Properties

MessageRequest : object

Defines the structure of messages sent to the background script for various actions. Kind: global typedef
Properties

SendResponse : function

A callback function used to send a response to a message sender in Chrome extensions. Kind: global typedef

ContextMenuOnClickData : object

Provides information about the context menu item that was clicked. Kind: global typedef
Properties

Tab : object

Represents a browser tab in Chrome. Kind: global typedef
Properties

OnInstalledDetails : object

Contains details about the installation or update event of the extension. Kind: global typedef
Properties

StorageChange : object

Describes the change in a single storage item, as provided by chrome.storage.onChanged. Kind: global typedef
Properties

StorageChanges : object.<string, StorageChange>

An object where each key is the name of a storage item that changed, and the value is a StorageChange object. Kind: global typedef