forked from SuperAtic/NutStash-Browser-Extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
21 lines (17 loc) · 808 Bytes
/
content.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// content.js
console.log("Content script loaded.");
// Close the extension popup when clicking outside of it.
window.addEventListener("click", (event) => {
const isPopup = event.target.closest("#openWalletButton");
if (!isPopup) {
chrome.extension.getBackgroundPage().chrome.extension.getViews({ type: "popup" })[0].close();
}
});
// You can add more logic here if needed.
//
// Check if the current page supports ecash payments by looking for the "ecash-payment" meta tag.
const supportsEcashPayments = document.querySelector('meta[name="cashu-payment"][content="true"]') !== null;
// Send a message to the background script with the result.
chrome.runtime.sendMessage({ supportsEcashPayments }, (response) => {
console.log("Supports ecash payments: ", response.supportsEcashPayments);
});