Skip to content

Commit 7f390ea

Browse files
committed
feat: implement browser API abstraction for compatibility with Chrome
1 parent 5ac0e6e commit 7f390ea

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Firefox Extension Project Instructions
22

33
## Overview
4-
This project is a Firefox extension. The codebase includes manifest files, localized messages, icons, and scripts for the extension's popup and options pages.
4+
This project is a Chrome and Firefox extension. The codebase includes manifest files, localized messages, icons, and scripts for the extension's popup and options pages.
55

66
## Getting Started
77
1. **Clone the repository:**

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# muench-dev Webhook Trigger Firefox Extension
1+
# muench-dev Webhook Trigger Browser Extension
22

3-
This Firefox extension allows you to manage and trigger webhooks directly from your browser. It is designed for users who want to quickly send HTTP requests (webhooks) to custom endpoints, such as automation services, APIs, or personal scripts.
3+
This browser extension allows you to manage and trigger webhooks directly from your browser. It works with both Firefox and Chrome. It is designed for users who want to quickly send HTTP requests (webhooks) to custom endpoints, such as automation services, APIs, or personal scripts.
44

55
## Features
66

@@ -13,7 +13,8 @@ This Firefox extension allows you to manage and trigger webhooks directly from y
1313
## Getting Started
1414

1515
1. **Install the Extension**
16-
- Load the extension in Firefox via `about:debugging` or package and install it from the [Add-ons Manager](about:addons).
16+
- **Firefox**: Load the extension in Firefox via `about:debugging` or package and install it from the [Add-ons Manager](about:addons).
17+
- **Chrome**: Load the extension in Chrome via `chrome://extensions` in developer mode by clicking "Load unpacked" and selecting the extension directory.
1718

1819
2. **Open the Options Page**
1920
- Right-click the extension icon and select "Options", or open it from the extension's popup menu.
@@ -41,7 +42,7 @@ This Firefox extension allows you to manage and trigger webhooks directly from y
4142

4243
![Popup Page Screenshot](./docs/images/popup.png)
4344

44-
1. Click the extension icon in the Firefox toolbar to open the popup.
45+
1. Click the extension icon in your browser's toolbar to open the popup.
4546
2. Select the webhook you want to trigger from the list.
4647
3. Click the "Send" or equivalent button to trigger the webhook.
4748

@@ -60,4 +61,3 @@ This Firefox extension allows you to manage and trigger webhooks directly from y
6061
## License
6162

6263
This project is licensed under the MIT License.
63-

options/options.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Polyfill for browser API to support Chrome and Firefox
2+
if (typeof window.browser === "undefined") {
3+
window.browser = window.chrome;
4+
}
5+
16
// Function to load and display webhooks
27
const loadWebhooks = async () => {
38
const { webhooks = [] } = await browser.storage.sync.get("webhooks");

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "firefox-extension-webhook-trigger",
2+
"name": "browser-extension-webhook-trigger",
33
"version": "1.0.0",
4-
"description": "This Firefox extension allows you to manage and trigger webhooks directly from your browser. It is designed for users who want to quickly send HTTP requests (webhooks) to custom endpoints, such as automation services, APIs, or personal scripts.",
4+
"description": "This browser extension allows you to manage and trigger webhooks directly from your browser. It works with both Firefox and Chrome. It is designed for users who want to quickly send HTTP requests (webhooks) to custom endpoints, such as automation services, APIs, or personal scripts.",
55
"main": "index.js",
66
"directories": {
77
"doc": "docs"

popup/popup.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Polyfill for browser API to support Chrome and Firefox
2+
if (typeof window !== "undefined" && typeof window.browser === "undefined") {
3+
window.browser = window.chrome;
4+
}
5+
16
document.addEventListener("DOMContentLoaded", async () => {
27
// Replace i18n placeholders
38
replaceI18nPlaceholders();

utils/utils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
// Shared utility functions
22

3+
// Polyfill for browser API to support Chrome and Firefox
4+
if (typeof window !== "undefined" && typeof window.browser === "undefined") {
5+
window.browser = window.chrome;
6+
}
7+
38
/**
49
* Replaces i18n placeholders in the HTML document.
510
* It targets elements with the 'data-i18n' attribute,

0 commit comments

Comments
 (0)