Glench / ExtPay

The JavaScript library for ExtensionPay.com — payments for your browser extensions, no server needed.
https://extensionpay.com
Other
483 stars 62 forks source link

I added extpay but it's still possible to use the extension without paying #176

Closed arnasp13 closed 9 months ago

arnasp13 commented 10 months ago

https://github.com/Glench/ExtPay/assets/17219190/2257b124-cbec-43db-aadd-f0cf5ea50c2b

importScripts("ExtPay.js"); // or `import` / `require` if using a bundler
const extpay = ExtPay("XXX");
extpay.startBackground(); // this line is required to use ExtPay in the rest of your extension

extpay.getUser().then((user) => {
  if (user.paid) {
    chrome.runtime.onInstalled.addListener(() => {
      chrome.contextMenus.create({
        id: "decodeVIN",
        title: "Decode VIN",
        contexts: ["selection"],
      });
    });

    chrome.contextMenus.onClicked.addListener((info, tab) => {
      if (info.menuItemId === "decodeVIN") {
        const vin = encodeURIComponent(info.selectionText);
        const url = chrome.runtime.getURL(`popup.html?vin=${vin}`);
        chrome.tabs.create({ url });
      }
    });
  } else {
    extpay.openPaymentPage();
  }
});