fck-honey 0.3.5 β†’ 0.3.6

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
@@ -1,15 +1,12 @@
1
1
  # fck-honey
2
- Open source lib for Merchants to detect if a customer has Honey browser extension installed
2
+ Open source lib for Merchants to detect if a customer has Honey browser extension installed [ [Demo πŸŽ₯](https://youtu.be/Em9Fjil8Xds) ]
3
3
 
4
- <img width="968" height="532" alt="image" src="https://github.com/user-attachments/assets/b0bcccd6-d922-436d-8b0d-dcd4334a9219" />
5
-
6
- ## Inspiration
7
- [MegaLag exposed Honey as a scam](https://www.youtube.com/watch?v=wwB3FmbcC88)
4
+ <img width="1307" height="561" alt="image" src="https://github.com/user-attachments/assets/33b2554b-fc90-4b4b-b917-4ed088664200" />
8
5
 
9
6
  ## Usage (Browser Global)
10
7
 
11
8
  ```html
12
- <script src="https://cdn.jsdelivr.net/npm/fck-honey@0/dist/honey-detect.js"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/fck-honey@latest/dist/honey-detect.min.js"></script>
13
10
  <script>
14
11
  window.fckHoney.listen((warn) => {
15
12
  // Decide how you want to handle this. Native warn function allows you to tell the user to disable Honey.
@@ -47,3 +44,6 @@ window.fckHoney.listen((warn) => {
47
44
  // Stop observing if nothing is detected within 10 seconds.
48
45
  }, { unbindAfterSeconds: 10 });
49
46
  ```
47
+
48
+ ## Inspiration
49
+ [MegaLag exposed Honey as a scam](https://www.youtube.com/watch?v=wwB3FmbcC88)
package/dist/auto.js ADDED
@@ -0,0 +1,231 @@
1
+ (function() {
2
+ // dist/bundle-tmp/version.js
3
+ var VERSION = "0.3.6";
4
+
5
+ // dist/bundle-tmp/core.js
6
+ var __assign = function() {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ var version = VERSION;
18
+ var DEFAULT_Z_NEAR_MAX = 214748e4;
19
+ var UUIDISH_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
20
+ var TARGET_SELECTOR = "div[id]";
21
+ var OVERLAY_STYLE_ID = "simple-overlay-styles";
22
+ function showOverlay(message) {
23
+ if (typeof document === "undefined")
24
+ return function() {
25
+ };
26
+ if (!document.getElementById(OVERLAY_STYLE_ID)) {
27
+ var style = document.createElement("style");
28
+ style.id = OVERLAY_STYLE_ID;
29
+ style.textContent = ".simple-overlay{position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:2147483647;display:flex;align-items:center;justify-content:center;pointer-events:all;}.simple-overlay-message{background:#ffffff;padding:16px 20px;border-radius:8px;font-size:14px;max-width:80%;text-align:center;box-shadow:0 10px 30px rgba(0,0,0,0.3);}";
30
+ document.head.appendChild(style);
31
+ }
32
+ var overlay = document.createElement("div");
33
+ overlay.className = "simple-overlay";
34
+ var messageEl = document.createElement("div");
35
+ messageEl.className = "simple-overlay-message";
36
+ messageEl.innerHTML = message;
37
+ overlay.appendChild(messageEl);
38
+ if (document.body) {
39
+ document.body.appendChild(overlay);
40
+ }
41
+ var prevOverflow = document.body ? document.body.style.overflow : "";
42
+ if (document.body)
43
+ document.body.style.overflow = "hidden";
44
+ return function hideOverlay() {
45
+ overlay.remove();
46
+ if (document.body)
47
+ document.body.style.overflow = prevOverflow;
48
+ };
49
+ }
50
+ function parseZIndex(cs, el) {
51
+ var computed = parseInt(cs.zIndex, 10);
52
+ if (isFinite(computed))
53
+ return computed;
54
+ var inline = parseInt(el.style.zIndex, 10);
55
+ return isFinite(inline) ? inline : null;
56
+ }
57
+ function looksLikeTargetDiv(el, zNearMax, uuidGate, debug) {
58
+ if (!el.id) {
59
+ if (debug)
60
+ console.log("+++ reject: no id", el);
61
+ return false;
62
+ }
63
+ if (uuidGate && !UUIDISH_RE.test(el.id)) {
64
+ if (debug)
65
+ console.log("+++ reject: uuid", el.id);
66
+ return false;
67
+ }
68
+ var inlineZ = parseInt(el.style.zIndex, 10);
69
+ if (!isFinite(inlineZ) || inlineZ < zNearMax) {
70
+ var cs_1 = getComputedStyle(el);
71
+ var z_1 = parseZIndex(cs_1, el);
72
+ if (z_1 === null || z_1 < zNearMax) {
73
+ if (debug)
74
+ console.log("+++ reject: z-index", z_1, cs_1.zIndex, el.style.zIndex, el);
75
+ return false;
76
+ }
77
+ if (cs_1.display === "none") {
78
+ if (debug)
79
+ console.log("+++ reject: display none", el);
80
+ return false;
81
+ }
82
+ if (el.shadowRoot) {
83
+ if (debug)
84
+ console.log("+++ reject: shadowRoot", el);
85
+ return false;
86
+ }
87
+ if (debug)
88
+ console.log("+++ match", el);
89
+ return true;
90
+ }
91
+ var cs = getComputedStyle(el);
92
+ var z = parseZIndex(cs, el);
93
+ if (z === null || z < zNearMax) {
94
+ if (debug)
95
+ console.log("+++ reject: z-index", z, cs.zIndex, el.style.zIndex, el);
96
+ return false;
97
+ }
98
+ if (cs.display === "none") {
99
+ if (debug)
100
+ console.log("+++ reject: display none", el);
101
+ return false;
102
+ }
103
+ if (el.shadowRoot) {
104
+ if (debug)
105
+ console.log("+++ reject: shadowRoot", el);
106
+ return false;
107
+ }
108
+ if (debug)
109
+ console.log("+++ match", el);
110
+ return true;
111
+ }
112
+ function scanElement(el, seen, zNearMax, uuidGate, debug, handleMatch) {
113
+ var _a;
114
+ if (el instanceof HTMLDivElement && el.matches(TARGET_SELECTOR)) {
115
+ if (seen.indexOf(el) === -1 && looksLikeTargetDiv(el, zNearMax, uuidGate, debug)) {
116
+ seen.push(el);
117
+ handleMatch(el);
118
+ }
119
+ }
120
+ var divs = (_a = el.querySelectorAll) === null || _a === void 0 ? void 0 : _a.call(el, TARGET_SELECTOR);
121
+ if (!divs)
122
+ return;
123
+ for (var i = 0; i < divs.length; i += 1) {
124
+ var d = divs[i];
125
+ if (seen.indexOf(d) === -1 && looksLikeTargetDiv(d, zNearMax, uuidGate, debug)) {
126
+ seen.push(d);
127
+ handleMatch(d);
128
+ }
129
+ }
130
+ }
131
+ function startHoneyOverlayObserver(options) {
132
+ var _a, _b, _c, _d, _e;
133
+ if (options === void 0) {
134
+ options = {};
135
+ }
136
+ var seen = [];
137
+ var zNearMax = (_a = options.zNearMax) !== null && _a !== void 0 ? _a : DEFAULT_Z_NEAR_MAX;
138
+ var uuidGate = (_b = options.uuidGate) !== null && _b !== void 0 ? _b : true;
139
+ var debug = (_c = options.debug) !== null && _c !== void 0 ? _c : false;
140
+ var removeHoney = (_d = options.removeHoney) !== null && _d !== void 0 ? _d : true;
141
+ var unbindAfterSeconds = options.unbindAfterSeconds;
142
+ var warn = function(message) {
143
+ return showOverlay(message);
144
+ };
145
+ var onMatch = (_e = options.onMatch) !== null && _e !== void 0 ? _e : (function() {
146
+ });
147
+ var matched = false;
148
+ var unbindTimer;
149
+ var handleMatch = function(el) {
150
+ matched = true;
151
+ if (typeof unbindTimer === "number") {
152
+ clearTimeout(unbindTimer);
153
+ unbindTimer = void 0;
154
+ }
155
+ if (removeHoney && el.parentNode)
156
+ el.parentNode.removeChild(el);
157
+ if (removeHoney) {
158
+ onMatch(warn);
159
+ } else {
160
+ onMatch(warn, el);
161
+ }
162
+ };
163
+ var mo = new MutationObserver(function(mutations) {
164
+ for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
165
+ var m = mutations_1[_i];
166
+ if (debug && document.body && (m.target === document.body || m.target instanceof Node && document.body.contains(m.target))) {
167
+ console.log("+++ body mutation", m.type, m.target);
168
+ }
169
+ }
170
+ for (var _a2 = 0, mutations_2 = mutations; _a2 < mutations_2.length; _a2++) {
171
+ var m = mutations_2[_a2];
172
+ if (m.type === "childList") {
173
+ if (m.addedNodes.length) {
174
+ for (var i = 0; i < m.addedNodes.length; i += 1) {
175
+ var node = m.addedNodes[i];
176
+ if (node.nodeType === Node.ELEMENT_NODE) {
177
+ scanElement(node, seen, zNearMax, uuidGate, debug, handleMatch);
178
+ }
179
+ }
180
+ }
181
+ if (m.target instanceof Element) {
182
+ scanElement(m.target, seen, zNearMax, uuidGate, debug, handleMatch);
183
+ }
184
+ } else if (m.type === "attributes") {
185
+ if (m.target instanceof Element) {
186
+ scanElement(m.target, seen, zNearMax, uuidGate, debug, handleMatch);
187
+ }
188
+ }
189
+ }
190
+ });
191
+ mo.observe(document.documentElement, {
192
+ subtree: true,
193
+ childList: true,
194
+ attributes: true,
195
+ attributeFilter: ["style", "class", "id"]
196
+ });
197
+ scanElement(document.documentElement, seen, zNearMax, uuidGate, debug, handleMatch);
198
+ if (typeof unbindAfterSeconds === "number" && unbindAfterSeconds > 0) {
199
+ unbindTimer = window.setTimeout(function() {
200
+ if (!matched) {
201
+ mo.disconnect();
202
+ }
203
+ }, unbindAfterSeconds * 1e3);
204
+ }
205
+ return {
206
+ stop: function() {
207
+ mo.disconnect();
208
+ if (typeof unbindTimer === "number") {
209
+ clearTimeout(unbindTimer);
210
+ }
211
+ }
212
+ };
213
+ }
214
+ function listen(onMatch, options) {
215
+ if (options === void 0) {
216
+ options = {};
217
+ }
218
+ return startHoneyOverlayObserver(__assign(__assign({}, options), { onMatch: onMatch }));
219
+ }
220
+
221
+ // dist/bundle-tmp/auto.js
222
+ var AUTO_MODAL_HTML = '<div class="modal" role="dialog" aria-modal="true" aria-labelledby="honey-modal-title"><h2 id="honey-modal-title">This site can\u2019t proceed with Honey enabled</h2><div style="display:flex;gap:8px;flex-wrap:wrap;margin:8px 0 12px 0;"><a href="https://help.joinhoney.com/article/26-how-do-i-uninstall-honey" target="_blank" rel="noopener noreferrer" style="display:block;padding:10px 12px;background:#e6eef7;color:#0b1b2b;text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:3px;border-radius:6px;flex:1 1 220px;">Please disable it to continue your checkout.</a><a href="https://www.youtube.com/watch?v=wwB3FmbcC88" target="_blank" rel="noopener noreferrer" style="display:block;padding:10px 12px;background:#e6eef7;color:#0b1b2b;text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:3px;border-radius:6px;flex:1 1 220px;">Here is why \uD83C\uDFA5</a></div></div>';
223
+ if (typeof window !== "undefined") {
224
+ window.fckHoney = window.fckHoney || {};
225
+ window.fckHoney.listen = listen;
226
+ window.fckHoney.version = version;
227
+ window.fckHoneyHandle = window.fckHoney.listen(function(warn, _el) {
228
+ warn(AUTO_MODAL_HTML);
229
+ });
230
+ }
231
+ })();
@@ -0,0 +1,10 @@
1
+ import { listen, version } from "./core";
2
+ var AUTO_MODAL_HTML = '<div class="modal" role="dialog" aria-modal="true" aria-labelledby="honey-modal-title"><h2 id="honey-modal-title">This site can’t proceed with Honey enabled</h2><div style="display:flex;gap:8px;flex-wrap:wrap;margin:8px 0 12px 0;"><a href="https://help.joinhoney.com/article/26-how-do-i-uninstall-honey" target="_blank" rel="noopener noreferrer" style="display:block;padding:10px 12px;background:#e6eef7;color:#0b1b2b;text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:3px;border-radius:6px;flex:1 1 220px;">Please disable it to continue your checkout.</a><a href="https://www.youtube.com/watch?v=wwB3FmbcC88" target="_blank" rel="noopener noreferrer" style="display:block;padding:10px 12px;background:#e6eef7;color:#0b1b2b;text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:3px;border-radius:6px;flex:1 1 220px;">Here is why πŸŽ₯</a></div></div>';
3
+ if (typeof window !== "undefined") {
4
+ window.fckHoney = window.fckHoney || {};
5
+ window.fckHoney.listen = listen;
6
+ window.fckHoney.version = version;
7
+ window.fckHoneyHandle = window.fckHoney.listen(function (warn, _el) {
8
+ warn(AUTO_MODAL_HTML);
9
+ });
10
+ }
@@ -1,2 +1,2 @@
1
1
  // Auto-generated from package.json. Do not edit by hand.
2
- export var VERSION = "0.3.5";
2
+ export var VERSION = "0.3.6";
@@ -1,2 +1,2 @@
1
1
  // Auto-generated from package.json. Do not edit by hand.
2
- export var VERSION = "0.3.5";
2
+ export var VERSION = "0.3.6";
@@ -1,6 +1,6 @@
1
1
  (function() {
2
2
  // dist/bundle-tmp/version.js
3
- var VERSION = "0.3.5";
3
+ var VERSION = "0.3.6";
4
4
 
5
5
  // dist/bundle-tmp/core.js
6
6
  var __assign = function() {
@@ -1,4 +1,4 @@
1
- export declare const version = "0.3.5";
1
+ export declare const version = "0.3.6";
2
2
  export type WarnCallback = (message: string) => () => void;
3
3
  export type MatchCallback = (warn: WarnCallback, el?: HTMLDivElement) => void;
4
4
  export interface ObserverOptions {
@@ -1 +1 @@
1
- export declare const VERSION = "0.3.5";
1
+ export declare const VERSION = "0.3.6";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fck-honey",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Detects Honey browser extension overlays for merchants.",
5
5
  "license": "MIT",
6
6
  "main": "dist/honey-detect.js",
@@ -18,7 +18,7 @@
18
18
  ],
19
19
  "scripts": {
20
20
  "prebuild": "node scripts/write-version.cjs",
21
- "build": "tsc -p tsconfig.esm.json && tsc -p tsconfig.bundle.json && esbuild dist/bundle-tmp/global.js --bundle --format=iife --platform=browser --target=es5 --outfile=dist/honey-detect.js",
21
+ "build": "tsc -p tsconfig.esm.json && tsc -p tsconfig.bundle.json && esbuild dist/bundle-tmp/global.js --bundle --format=iife --platform=browser --target=es5 --outfile=dist/honey-detect.js && esbuild dist/bundle-tmp/auto.js --bundle --format=iife --platform=browser --target=es5 --outfile=dist/auto.js",
22
22
  "prepublishOnly": "npm run build && node scripts/check-version.cjs",
23
23
  "clean": "rm -rf dist"
24
24
  },