fck-honey 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,10 +9,9 @@ Open source lib for Merchants to detect if an end user has Honey browser extensi
9
9
  ```html
10
10
  <script src="https://cdn.jsdelivr.net/npm/fck-honey/dist/honey-detect.min.js"></script>
11
11
  <script>
12
- window.fckHoney.listen((el) => {
13
- // Decide how you want to handle this.
14
- // Example: pause checkout and notify the user.
15
- console.log("Honey overlay detected:", el);
12
+ window.fckHoney.listen((warn) => {
13
+ // Decide how you want to handle this. Native warn function allows you to tell the user to disable Honey.
14
+ warn("You must disable the Honey extension to continue.");
16
15
  });
17
16
  </script>
18
17
  ```
@@ -26,19 +25,17 @@ npm install fck-honey
26
25
  ```js
27
26
  import { listen } from "fck-honey";
28
27
 
29
- listen((el) => {
30
- // Decide how you want to handle this.
31
- // Example: pause checkout and notify the user.
32
- console.log("Honey overlay detected:", el);
28
+ listen((warn) => {
29
+ // Decide how you want to handle this. Native warn function allows you to tell the user to disable Honey.
30
+ warn("You must disable the Honey extension to continue.");
33
31
  });
34
32
  ```
35
33
 
36
34
  ## Advanced Options
37
35
 
38
36
  ```js
39
- window.fckHoney.listen((el, warn) => {
40
- // Optional: the element is removed automatically by default.
41
- // warn() shows a built-in overlay message (returns a hide function).
42
- warn("You must disable the Honey extension to continue.");
43
- }, { removeHoney: true });
37
+ window.fckHoney.listen((warn, el) => {
38
+ // removeHoney defaults to true (element is auto-removed).
39
+ // Set removeHoney to false if you want to keep the Honey element for some reason.
40
+ }, { removeHoney: false });
44
41
  ```
package/dist/esm/index.js CHANGED
@@ -88,7 +88,12 @@ function scanElement(el, seen, zNearMax, uuidGate, debug, removeHoney, onMatch,
88
88
  seen.push(el);
89
89
  if (removeHoney && el.parentNode)
90
90
  el.parentNode.removeChild(el);
91
- onMatch(el, warn);
91
+ if (removeHoney) {
92
+ onMatch(warn);
93
+ }
94
+ else {
95
+ onMatch(warn, el);
96
+ }
92
97
  }
93
98
  }
94
99
  var divs = (_a = el.querySelectorAll) === null || _a === void 0 ? void 0 : _a.call(el, TARGET_SELECTOR);
@@ -100,7 +105,12 @@ function scanElement(el, seen, zNearMax, uuidGate, debug, removeHoney, onMatch,
100
105
  seen.push(d);
101
106
  if (removeHoney && d.parentNode)
102
107
  d.parentNode.removeChild(d);
103
- onMatch(d, warn);
108
+ if (removeHoney) {
109
+ onMatch(warn);
110
+ }
111
+ else {
112
+ onMatch(warn, d);
113
+ }
104
114
  }
105
115
  }
106
116
  }
@@ -89,7 +89,12 @@ function scanElement(el, seen, zNearMax, uuidGate, debug, removeHoney, onMatch,
89
89
  seen.push(el);
90
90
  if (removeHoney && el.parentNode)
91
91
  el.parentNode.removeChild(el);
92
- onMatch(el, warn);
92
+ if (removeHoney) {
93
+ onMatch(warn);
94
+ }
95
+ else {
96
+ onMatch(warn, el);
97
+ }
93
98
  }
94
99
  }
95
100
  var divs = (_a = el.querySelectorAll) === null || _a === void 0 ? void 0 : _a.call(el, TARGET_SELECTOR);
@@ -101,7 +106,12 @@ function scanElement(el, seen, zNearMax, uuidGate, debug, removeHoney, onMatch,
101
106
  seen.push(d);
102
107
  if (removeHoney && d.parentNode)
103
108
  d.parentNode.removeChild(d);
104
- onMatch(d, warn);
109
+ if (removeHoney) {
110
+ onMatch(warn);
111
+ }
112
+ else {
113
+ onMatch(warn, d);
114
+ }
105
115
  }
106
116
  }
107
117
  }
@@ -1,5 +1,5 @@
1
1
  export type WarnCallback = (message: string) => () => void;
2
- export type MatchCallback = (el: HTMLDivElement, warn: WarnCallback) => void;
2
+ export type MatchCallback = (warn: WarnCallback, el?: HTMLDivElement) => void;
3
3
  export interface ObserverOptions {
4
4
  onMatch?: MatchCallback;
5
5
  uuidGate?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fck-honey",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Detects Honey browser extension overlays for merchants.",
5
5
  "license": "MIT",
6
6
  "main": "dist/honey-detect.js",