A TypeScript library for retrieving notifications saved by Chromium-based browsers.
npm install chromium-notification-retrieverconst { Retriever } = require("chromium-notification-retriever");
// Specify the path to the LevelDB database where your browser stores notification information
// E.g. "C:/Users/<username>/AppData/Local/Microsoft/Edge/User Data/Default/Platform Notifications"
// for a default Edge installation on Windows
const dbPath = "/path/to/your/chromium/db";
// Optional: Provide configuration options
const options = {
refreshOnRetrieve: true, // Whether to refresh the database on each retrieval (default: true)
watchInterval: 1000, // Time between each check for new notifications (default: 3000)
};
// Create a new Retriever instance
const retriever = new Retriever(dbPath, options);
// Retrieve notifications
retriever.retrieve({ limit: 10 }).then((notifications) => {
notifications.forEach((notification) => {
// Access notifications
console.log(notification);
});
});
// Watch for new notifications
retriever.watch((notification) => {
// This callback will be called whenever a new notification is found
console.log(notification);
});
// Retrieve a specific notification by its key
const key = "notification_key";
const notification = await retriever.get(key);
if (notification) console.log(notification);
else console.log("Notification not found.");Creates a new Retriever instance.
dbPath: Path to the LevelDB database where the browser stores notification information.options(optional): Configuration options.
Makes a new copy of the notification database with up-to-date notifications.
Unnecessary if refreshOnRetrieve is enabled.
Retrieves notifications from the database. .
limit(optional): Maximum number of notifications to retrieve.refresh(optional): OverridesrefreshOnRetrieve.
Retrieves a specific notification by its key. If passed, refresh overrides refreshOnRetrieve.
key: The key of the notification.refresh(optional): OverridesrefreshOnRetrieve.
Returns a notification if one exists with that key, or undefined otherwise.
Calls listener for every new notification found.
listener: Function to be called whenever a new notification is found.
Returns a function that removes the listener.
Closes and deletes the copy of the notification database.
Note that old copies of databases are always deleted when you import Retriever, so calling this might not be necessary.
This project is licensed under the MIT License.