Glench / ExtPay

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

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

Closed arnasp13 closed 1 year ago

arnasp13 commented 1 year 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();
  }
});