Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions popup/popup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@


/**
* Helper function to create a webhook button element.
* @param {Object} webhook - The webhook data object.
* @returns {HTMLButtonElement} The created button element.
*/
function createWebhookButton(webhook) {
const button = document.createElement("button");
const displayLabel = `${webhook.emoji ? webhook.emoji + ' ' : ''}${webhook.label}`;
button.textContent = displayLabel;
button.dataset.url = webhook.url;
button.dataset.label = displayLabel;
button.dataset.webhookId = webhook.id;
button.classList.add("webhook-btn");
return button;
}

document.addEventListener("DOMContentLoaded", async () => {
const browserAPI = window.getBrowserAPI();
// Replace i18n placeholders
Expand Down Expand Up @@ -64,13 +80,7 @@ document.addEventListener("DOMContentLoaded", async () => {

// Create a button for each webhook in this group
groupWebhooks.forEach((webhook) => {
const button = document.createElement("button");
const displayLabel = `${webhook.emoji ? webhook.emoji + ' ' : ''}${webhook.label}`;
button.textContent = displayLabel;
button.dataset.url = webhook.url;
button.dataset.label = displayLabel;
button.dataset.webhookId = webhook.id;
button.classList.add("webhook-btn");
const button = createWebhookButton(webhook);
buttonsContainer.appendChild(button);
});
}
Expand All @@ -87,13 +97,7 @@ document.addEventListener("DOMContentLoaded", async () => {

// Create a button for each ungrouped webhook
ungroupedWebhooks.forEach((webhook) => {
const button = document.createElement("button");
const displayLabel = `${webhook.emoji ? webhook.emoji + ' ' : ''}${webhook.label}`;
button.textContent = displayLabel;
button.dataset.url = webhook.url;
button.dataset.label = displayLabel;
button.dataset.webhookId = webhook.id;
button.classList.add("webhook-btn");
const button = createWebhookButton(webhook);
buttonsContainer.appendChild(button);
});
}
Expand Down