fck-honey 0.2.2 → 0.3.1

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,5 +1,7 @@
1
1
  # fck-honey
2
- Open source lib for Merchants to detect if an end user has Honey browser extension installed
2
+ Open source lib for Merchants to detect if a customer has Honey browser extension installed
3
+
4
+ <img width="968" height="532" alt="image" src="https://github.com/user-attachments/assets/b0bcccd6-d922-436d-8b0d-dcd4334a9219" />
3
5
 
4
6
  ## Inspiration
5
7
  [MegaLag exposed Honey as a scam](https://www.youtube.com/watch?v=wwB3FmbcC88)
@@ -7,7 +9,7 @@ Open source lib for Merchants to detect if an end user has Honey browser extensi
7
9
  ## Usage (Browser Global)
8
10
 
9
11
  ```html
10
- <script src="https://cdn.jsdelivr.net/npm/fck-honey/dist/honey-detect.min.js"></script>
12
+ <script src="https://cdn.jsdelivr.net/npm/fck-honey@0/dist/honey-detect.js"></script>
11
13
  <script>
12
14
  window.fckHoney.listen((warn) => {
13
15
  // Decide how you want to handle this. Native warn function allows you to tell the user to disable Honey.
@@ -0,0 +1,174 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { VERSION } from "./version";
13
+ export var version = VERSION;
14
+ var DEFAULT_Z_NEAR_MAX = 2147480000;
15
+ var UUIDISH_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
16
+ var TARGET_SELECTOR = "div[id]";
17
+ var OVERLAY_STYLE_ID = "simple-overlay-styles";
18
+ function showOverlay(message) {
19
+ if (typeof document === "undefined")
20
+ return function () { };
21
+ if (!document.getElementById(OVERLAY_STYLE_ID)) {
22
+ var style = document.createElement("style");
23
+ style.id = OVERLAY_STYLE_ID;
24
+ style.textContent =
25
+ ".simple-overlay{position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:999999;display:flex;align-items:center;justify-content:center;pointer-events:all;}" +
26
+ ".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);}";
27
+ document.head.appendChild(style);
28
+ }
29
+ var overlay = document.createElement("div");
30
+ overlay.className = "simple-overlay";
31
+ var messageEl = document.createElement("div");
32
+ messageEl.className = "simple-overlay-message";
33
+ messageEl.innerHTML = message;
34
+ overlay.appendChild(messageEl);
35
+ if (document.body) {
36
+ document.body.appendChild(overlay);
37
+ }
38
+ var prevOverflow = document.body ? document.body.style.overflow : "";
39
+ if (document.body)
40
+ document.body.style.overflow = "hidden";
41
+ return function hideOverlay() {
42
+ overlay.remove();
43
+ if (document.body)
44
+ document.body.style.overflow = prevOverflow;
45
+ };
46
+ }
47
+ function parseZIndex(cs, el) {
48
+ var computed = parseInt(cs.zIndex, 10);
49
+ if (isFinite(computed))
50
+ return computed;
51
+ var inline = parseInt(el.style.zIndex, 10);
52
+ return isFinite(inline) ? inline : null;
53
+ }
54
+ function looksLikeTargetDiv(el, zNearMax, uuidGate, debug) {
55
+ if (!el.id) {
56
+ if (debug)
57
+ console.log("+++ reject: no id", el);
58
+ return false;
59
+ }
60
+ if (uuidGate && !UUIDISH_RE.test(el.id)) {
61
+ if (debug)
62
+ console.log("+++ reject: uuid", el.id);
63
+ return false;
64
+ }
65
+ var cs = getComputedStyle(el);
66
+ var z = parseZIndex(cs, el);
67
+ if (z === null || z < zNearMax) {
68
+ if (debug)
69
+ console.log("+++ reject: z-index", z, cs.zIndex, el.style.zIndex, el);
70
+ return false;
71
+ }
72
+ if (cs.display === "none") {
73
+ if (debug)
74
+ console.log("+++ reject: display none", el);
75
+ return false;
76
+ }
77
+ if (el.shadowRoot) {
78
+ if (debug)
79
+ console.log("+++ reject: shadowRoot", el);
80
+ return false;
81
+ }
82
+ if (debug)
83
+ console.log("+++ match", el);
84
+ return true;
85
+ }
86
+ function scanElement(el, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn) {
87
+ var _a;
88
+ if (el instanceof HTMLDivElement && el.matches(TARGET_SELECTOR)) {
89
+ if (seen.indexOf(el) === -1 && looksLikeTargetDiv(el, zNearMax, uuidGate, debug)) {
90
+ seen.push(el);
91
+ if (removeHoney && el.parentNode)
92
+ el.parentNode.removeChild(el);
93
+ if (removeHoney) {
94
+ onMatch(warn);
95
+ }
96
+ else {
97
+ onMatch(warn, el);
98
+ }
99
+ }
100
+ }
101
+ var divs = (_a = el.querySelectorAll) === null || _a === void 0 ? void 0 : _a.call(el, TARGET_SELECTOR);
102
+ if (!divs)
103
+ return;
104
+ for (var i = 0; i < divs.length; i += 1) {
105
+ var d = divs[i];
106
+ if (seen.indexOf(d) === -1 && looksLikeTargetDiv(d, zNearMax, uuidGate, debug)) {
107
+ seen.push(d);
108
+ if (removeHoney && d.parentNode)
109
+ d.parentNode.removeChild(d);
110
+ if (removeHoney) {
111
+ onMatch(warn);
112
+ }
113
+ else {
114
+ onMatch(warn, d);
115
+ }
116
+ }
117
+ }
118
+ }
119
+ export function startHoneyOverlayObserver(options) {
120
+ var _a, _b, _c, _d, _e;
121
+ if (options === void 0) { options = {}; }
122
+ var seen = [];
123
+ var zNearMax = (_a = options.zNearMax) !== null && _a !== void 0 ? _a : DEFAULT_Z_NEAR_MAX;
124
+ var uuidGate = (_b = options.uuidGate) !== null && _b !== void 0 ? _b : true;
125
+ var debug = (_c = options.debug) !== null && _c !== void 0 ? _c : false;
126
+ var removeHoney = (_d = options.removeHoney) !== null && _d !== void 0 ? _d : true;
127
+ var warn = function (message) { return showOverlay(message); };
128
+ var onMatch = (_e = options.onMatch) !== null && _e !== void 0 ? _e : (function () { });
129
+ var mo = new MutationObserver(function (mutations) {
130
+ for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
131
+ var m = mutations_1[_i];
132
+ if (debug &&
133
+ document.body &&
134
+ (m.target === document.body || (m.target instanceof Node && document.body.contains(m.target)))) {
135
+ console.log("+++ body mutation", m.type, m.target);
136
+ }
137
+ }
138
+ for (var _a = 0, mutations_2 = mutations; _a < mutations_2.length; _a++) {
139
+ var m = mutations_2[_a];
140
+ if (m.type === "childList") {
141
+ if (m.addedNodes.length) {
142
+ for (var i = 0; i < m.addedNodes.length; i += 1) {
143
+ var node = m.addedNodes[i];
144
+ if (node.nodeType === Node.ELEMENT_NODE) {
145
+ scanElement(node, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
146
+ }
147
+ }
148
+ }
149
+ if (m.target instanceof Element) {
150
+ scanElement(m.target, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
151
+ }
152
+ }
153
+ else if (m.type === "attributes") {
154
+ if (m.target instanceof Element) {
155
+ scanElement(m.target, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
156
+ }
157
+ }
158
+ }
159
+ });
160
+ mo.observe(document.documentElement, {
161
+ subtree: true,
162
+ childList: true,
163
+ attributes: true,
164
+ attributeFilter: ["style", "class", "id"]
165
+ });
166
+ scanElement(document.documentElement, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
167
+ return {
168
+ stop: function () { return mo.disconnect(); }
169
+ };
170
+ }
171
+ export function listen(onMatch, options) {
172
+ if (options === void 0) { options = {}; }
173
+ return startHoneyOverlayObserver(__assign(__assign({}, options), { onMatch: onMatch }));
174
+ }
@@ -0,0 +1,7 @@
1
+ import { listen, startHoneyOverlayObserver, version } from "./core";
2
+ if (typeof window !== "undefined") {
3
+ window.fckHoney = window.fckHoney || {};
4
+ window.fckHoney.startHoneyOverlayObserver = startHoneyOverlayObserver;
5
+ window.fckHoney.listen = listen;
6
+ window.fckHoney.version = version;
7
+ }
@@ -0,0 +1,2 @@
1
+ // Auto-generated from package.json. Do not edit by hand.
2
+ export var VERSION = "0.3.1";
@@ -0,0 +1,174 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { VERSION } from "./version";
13
+ export var version = VERSION;
14
+ var DEFAULT_Z_NEAR_MAX = 2147480000;
15
+ var UUIDISH_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
16
+ var TARGET_SELECTOR = "div[id]";
17
+ var OVERLAY_STYLE_ID = "simple-overlay-styles";
18
+ function showOverlay(message) {
19
+ if (typeof document === "undefined")
20
+ return function () { };
21
+ if (!document.getElementById(OVERLAY_STYLE_ID)) {
22
+ var style = document.createElement("style");
23
+ style.id = OVERLAY_STYLE_ID;
24
+ style.textContent =
25
+ ".simple-overlay{position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:999999;display:flex;align-items:center;justify-content:center;pointer-events:all;}" +
26
+ ".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);}";
27
+ document.head.appendChild(style);
28
+ }
29
+ var overlay = document.createElement("div");
30
+ overlay.className = "simple-overlay";
31
+ var messageEl = document.createElement("div");
32
+ messageEl.className = "simple-overlay-message";
33
+ messageEl.innerHTML = message;
34
+ overlay.appendChild(messageEl);
35
+ if (document.body) {
36
+ document.body.appendChild(overlay);
37
+ }
38
+ var prevOverflow = document.body ? document.body.style.overflow : "";
39
+ if (document.body)
40
+ document.body.style.overflow = "hidden";
41
+ return function hideOverlay() {
42
+ overlay.remove();
43
+ if (document.body)
44
+ document.body.style.overflow = prevOverflow;
45
+ };
46
+ }
47
+ function parseZIndex(cs, el) {
48
+ var computed = parseInt(cs.zIndex, 10);
49
+ if (isFinite(computed))
50
+ return computed;
51
+ var inline = parseInt(el.style.zIndex, 10);
52
+ return isFinite(inline) ? inline : null;
53
+ }
54
+ function looksLikeTargetDiv(el, zNearMax, uuidGate, debug) {
55
+ if (!el.id) {
56
+ if (debug)
57
+ console.log("+++ reject: no id", el);
58
+ return false;
59
+ }
60
+ if (uuidGate && !UUIDISH_RE.test(el.id)) {
61
+ if (debug)
62
+ console.log("+++ reject: uuid", el.id);
63
+ return false;
64
+ }
65
+ var cs = getComputedStyle(el);
66
+ var z = parseZIndex(cs, el);
67
+ if (z === null || z < zNearMax) {
68
+ if (debug)
69
+ console.log("+++ reject: z-index", z, cs.zIndex, el.style.zIndex, el);
70
+ return false;
71
+ }
72
+ if (cs.display === "none") {
73
+ if (debug)
74
+ console.log("+++ reject: display none", el);
75
+ return false;
76
+ }
77
+ if (el.shadowRoot) {
78
+ if (debug)
79
+ console.log("+++ reject: shadowRoot", el);
80
+ return false;
81
+ }
82
+ if (debug)
83
+ console.log("+++ match", el);
84
+ return true;
85
+ }
86
+ function scanElement(el, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn) {
87
+ var _a;
88
+ if (el instanceof HTMLDivElement && el.matches(TARGET_SELECTOR)) {
89
+ if (seen.indexOf(el) === -1 && looksLikeTargetDiv(el, zNearMax, uuidGate, debug)) {
90
+ seen.push(el);
91
+ if (removeHoney && el.parentNode)
92
+ el.parentNode.removeChild(el);
93
+ if (removeHoney) {
94
+ onMatch(warn);
95
+ }
96
+ else {
97
+ onMatch(warn, el);
98
+ }
99
+ }
100
+ }
101
+ var divs = (_a = el.querySelectorAll) === null || _a === void 0 ? void 0 : _a.call(el, TARGET_SELECTOR);
102
+ if (!divs)
103
+ return;
104
+ for (var i = 0; i < divs.length; i += 1) {
105
+ var d = divs[i];
106
+ if (seen.indexOf(d) === -1 && looksLikeTargetDiv(d, zNearMax, uuidGate, debug)) {
107
+ seen.push(d);
108
+ if (removeHoney && d.parentNode)
109
+ d.parentNode.removeChild(d);
110
+ if (removeHoney) {
111
+ onMatch(warn);
112
+ }
113
+ else {
114
+ onMatch(warn, d);
115
+ }
116
+ }
117
+ }
118
+ }
119
+ export function startHoneyOverlayObserver(options) {
120
+ var _a, _b, _c, _d, _e;
121
+ if (options === void 0) { options = {}; }
122
+ var seen = [];
123
+ var zNearMax = (_a = options.zNearMax) !== null && _a !== void 0 ? _a : DEFAULT_Z_NEAR_MAX;
124
+ var uuidGate = (_b = options.uuidGate) !== null && _b !== void 0 ? _b : true;
125
+ var debug = (_c = options.debug) !== null && _c !== void 0 ? _c : false;
126
+ var removeHoney = (_d = options.removeHoney) !== null && _d !== void 0 ? _d : true;
127
+ var warn = function (message) { return showOverlay(message); };
128
+ var onMatch = (_e = options.onMatch) !== null && _e !== void 0 ? _e : (function () { });
129
+ var mo = new MutationObserver(function (mutations) {
130
+ for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
131
+ var m = mutations_1[_i];
132
+ if (debug &&
133
+ document.body &&
134
+ (m.target === document.body || (m.target instanceof Node && document.body.contains(m.target)))) {
135
+ console.log("+++ body mutation", m.type, m.target);
136
+ }
137
+ }
138
+ for (var _a = 0, mutations_2 = mutations; _a < mutations_2.length; _a++) {
139
+ var m = mutations_2[_a];
140
+ if (m.type === "childList") {
141
+ if (m.addedNodes.length) {
142
+ for (var i = 0; i < m.addedNodes.length; i += 1) {
143
+ var node = m.addedNodes[i];
144
+ if (node.nodeType === Node.ELEMENT_NODE) {
145
+ scanElement(node, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
146
+ }
147
+ }
148
+ }
149
+ if (m.target instanceof Element) {
150
+ scanElement(m.target, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
151
+ }
152
+ }
153
+ else if (m.type === "attributes") {
154
+ if (m.target instanceof Element) {
155
+ scanElement(m.target, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
156
+ }
157
+ }
158
+ }
159
+ });
160
+ mo.observe(document.documentElement, {
161
+ subtree: true,
162
+ childList: true,
163
+ attributes: true,
164
+ attributeFilter: ["style", "class", "id"]
165
+ });
166
+ scanElement(document.documentElement, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
167
+ return {
168
+ stop: function () { return mo.disconnect(); }
169
+ };
170
+ }
171
+ export function listen(onMatch, options) {
172
+ if (options === void 0) { options = {}; }
173
+ return startHoneyOverlayObserver(__assign(__assign({}, options), { onMatch: onMatch }));
174
+ }
package/dist/esm/index.js CHANGED
@@ -1,172 +1 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var DEFAULT_Z_NEAR_MAX = 2147480000;
13
- var UUIDISH_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
14
- var TARGET_SELECTOR = "div[id]";
15
- var OVERLAY_STYLE_ID = "simple-overlay-styles";
16
- function showOverlay(message) {
17
- if (typeof document === "undefined")
18
- return function () { };
19
- if (!document.getElementById(OVERLAY_STYLE_ID)) {
20
- var style = document.createElement("style");
21
- style.id = OVERLAY_STYLE_ID;
22
- style.textContent =
23
- ".simple-overlay{position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:999999;display:flex;align-items:center;justify-content:center;pointer-events:all;}" +
24
- ".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);}";
25
- document.head.appendChild(style);
26
- }
27
- var overlay = document.createElement("div");
28
- overlay.className = "simple-overlay";
29
- var messageEl = document.createElement("div");
30
- messageEl.className = "simple-overlay-message";
31
- messageEl.innerHTML = message;
32
- overlay.appendChild(messageEl);
33
- if (document.body) {
34
- document.body.appendChild(overlay);
35
- }
36
- var prevOverflow = document.body ? document.body.style.overflow : "";
37
- if (document.body)
38
- document.body.style.overflow = "hidden";
39
- return function hideOverlay() {
40
- overlay.remove();
41
- if (document.body)
42
- document.body.style.overflow = prevOverflow;
43
- };
44
- }
45
- function parseZIndex(cs, el) {
46
- var computed = parseInt(cs.zIndex, 10);
47
- if (isFinite(computed))
48
- return computed;
49
- var inline = parseInt(el.style.zIndex, 10);
50
- return isFinite(inline) ? inline : null;
51
- }
52
- function looksLikeTargetDiv(el, zNearMax, uuidGate, debug) {
53
- if (!el.id) {
54
- if (debug)
55
- console.log("+++ reject: no id", el);
56
- return false;
57
- }
58
- if (uuidGate && !UUIDISH_RE.test(el.id)) {
59
- if (debug)
60
- console.log("+++ reject: uuid", el.id);
61
- return false;
62
- }
63
- var cs = getComputedStyle(el);
64
- var z = parseZIndex(cs, el);
65
- if (z === null || z < zNearMax) {
66
- if (debug)
67
- console.log("+++ reject: z-index", z, cs.zIndex, el.style.zIndex, el);
68
- return false;
69
- }
70
- if (cs.display === "none") {
71
- if (debug)
72
- console.log("+++ reject: display none", el);
73
- return false;
74
- }
75
- if (el.shadowRoot) {
76
- if (debug)
77
- console.log("+++ reject: shadowRoot", el);
78
- return false;
79
- }
80
- if (debug)
81
- console.log("+++ match", el);
82
- return true;
83
- }
84
- function scanElement(el, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn) {
85
- var _a;
86
- if (el instanceof HTMLDivElement && el.matches(TARGET_SELECTOR)) {
87
- if (seen.indexOf(el) === -1 && looksLikeTargetDiv(el, zNearMax, uuidGate, debug)) {
88
- seen.push(el);
89
- if (removeHoney && el.parentNode)
90
- el.parentNode.removeChild(el);
91
- if (removeHoney) {
92
- onMatch(warn);
93
- }
94
- else {
95
- onMatch(warn, el);
96
- }
97
- }
98
- }
99
- var divs = (_a = el.querySelectorAll) === null || _a === void 0 ? void 0 : _a.call(el, TARGET_SELECTOR);
100
- if (!divs)
101
- return;
102
- for (var i = 0; i < divs.length; i += 1) {
103
- var d = divs[i];
104
- if (seen.indexOf(d) === -1 && looksLikeTargetDiv(d, zNearMax, uuidGate, debug)) {
105
- seen.push(d);
106
- if (removeHoney && d.parentNode)
107
- d.parentNode.removeChild(d);
108
- if (removeHoney) {
109
- onMatch(warn);
110
- }
111
- else {
112
- onMatch(warn, d);
113
- }
114
- }
115
- }
116
- }
117
- export function startHoneyOverlayObserver(options) {
118
- var _a, _b, _c, _d, _e;
119
- if (options === void 0) { options = {}; }
120
- var seen = [];
121
- var zNearMax = (_a = options.zNearMax) !== null && _a !== void 0 ? _a : DEFAULT_Z_NEAR_MAX;
122
- var uuidGate = (_b = options.uuidGate) !== null && _b !== void 0 ? _b : true;
123
- var debug = (_c = options.debug) !== null && _c !== void 0 ? _c : false;
124
- var removeHoney = (_d = options.removeHoney) !== null && _d !== void 0 ? _d : true;
125
- var warn = function (message) { return showOverlay(message); };
126
- var onMatch = (_e = options.onMatch) !== null && _e !== void 0 ? _e : (function () { });
127
- var mo = new MutationObserver(function (mutations) {
128
- for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
129
- var m = mutations_1[_i];
130
- if (debug &&
131
- document.body &&
132
- (m.target === document.body || (m.target instanceof Node && document.body.contains(m.target)))) {
133
- console.log("+++ body mutation", m.type, m.target);
134
- }
135
- }
136
- for (var _a = 0, mutations_2 = mutations; _a < mutations_2.length; _a++) {
137
- var m = mutations_2[_a];
138
- if (m.type === "childList") {
139
- if (m.addedNodes.length) {
140
- for (var i = 0; i < m.addedNodes.length; i += 1) {
141
- var node = m.addedNodes[i];
142
- if (node.nodeType === Node.ELEMENT_NODE) {
143
- scanElement(node, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
144
- }
145
- }
146
- }
147
- if (m.target instanceof Element) {
148
- scanElement(m.target, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
149
- }
150
- }
151
- else if (m.type === "attributes") {
152
- if (m.target instanceof Element) {
153
- scanElement(m.target, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
154
- }
155
- }
156
- }
157
- });
158
- mo.observe(document.documentElement, {
159
- subtree: true,
160
- childList: true,
161
- attributes: true,
162
- attributeFilter: ["style", "class", "id"]
163
- });
164
- scanElement(document.documentElement, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
165
- return {
166
- stop: function () { return mo.disconnect(); }
167
- };
168
- }
169
- export function listen(onMatch, options) {
170
- if (options === void 0) { options = {}; }
171
- return startHoneyOverlayObserver(__assign(__assign({}, options), { onMatch: onMatch }));
172
- }
1
+ export * from "./core";
@@ -0,0 +1,2 @@
1
+ // Auto-generated from package.json. Do not edit by hand.
2
+ export var VERSION = "0.3.1";
@@ -1,29 +1,33 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
1
+ (function() {
2
+ // dist/bundle-tmp/version.js
3
+ var VERSION = "0.3.1";
4
+
5
+ // dist/bundle-tmp/core.js
6
+ var __assign = function() {
3
7
  __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return 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;
10
14
  };
11
15
  return __assign.apply(this, arguments);
12
- };
13
- var DEFAULT_Z_NEAR_MAX = 2147480000;
14
- var UUIDISH_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
15
- var TARGET_SELECTOR = "div[id]";
16
- var OVERLAY_STYLE_ID = "simple-overlay-styles";
17
- function showOverlay(message) {
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) {
18
23
  if (typeof document === "undefined")
19
- return function () { };
24
+ return function() {
25
+ };
20
26
  if (!document.getElementById(OVERLAY_STYLE_ID)) {
21
- var style = document.createElement("style");
22
- style.id = OVERLAY_STYLE_ID;
23
- style.textContent =
24
- ".simple-overlay{position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:999999;display:flex;align-items:center;justify-content:center;pointer-events:all;}" +
25
- ".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);}";
26
- document.head.appendChild(style);
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:999999;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);
27
31
  }
28
32
  var overlay = document.createElement("div");
29
33
  overlay.className = "simple-overlay";
@@ -32,147 +36,155 @@ function showOverlay(message) {
32
36
  messageEl.innerHTML = message;
33
37
  overlay.appendChild(messageEl);
34
38
  if (document.body) {
35
- document.body.appendChild(overlay);
39
+ document.body.appendChild(overlay);
36
40
  }
37
41
  var prevOverflow = document.body ? document.body.style.overflow : "";
38
42
  if (document.body)
39
- document.body.style.overflow = "hidden";
43
+ document.body.style.overflow = "hidden";
40
44
  return function hideOverlay() {
41
- overlay.remove();
42
- if (document.body)
43
- document.body.style.overflow = prevOverflow;
45
+ overlay.remove();
46
+ if (document.body)
47
+ document.body.style.overflow = prevOverflow;
44
48
  };
45
- }
46
- function parseZIndex(cs, el) {
49
+ }
50
+ function parseZIndex(cs, el) {
47
51
  var computed = parseInt(cs.zIndex, 10);
48
52
  if (isFinite(computed))
49
- return computed;
53
+ return computed;
50
54
  var inline = parseInt(el.style.zIndex, 10);
51
55
  return isFinite(inline) ? inline : null;
52
- }
53
- function looksLikeTargetDiv(el, zNearMax, uuidGate, debug) {
56
+ }
57
+ function looksLikeTargetDiv(el, zNearMax, uuidGate, debug) {
54
58
  if (!el.id) {
55
- if (debug)
56
- console.log("+++ reject: no id", el);
57
- return false;
59
+ if (debug)
60
+ console.log("+++ reject: no id", el);
61
+ return false;
58
62
  }
59
63
  if (uuidGate && !UUIDISH_RE.test(el.id)) {
60
- if (debug)
61
- console.log("+++ reject: uuid", el.id);
62
- return false;
64
+ if (debug)
65
+ console.log("+++ reject: uuid", el.id);
66
+ return false;
63
67
  }
64
68
  var cs = getComputedStyle(el);
65
69
  var z = parseZIndex(cs, el);
66
70
  if (z === null || z < zNearMax) {
67
- if (debug)
68
- console.log("+++ reject: z-index", z, cs.zIndex, el.style.zIndex, el);
69
- return false;
71
+ if (debug)
72
+ console.log("+++ reject: z-index", z, cs.zIndex, el.style.zIndex, el);
73
+ return false;
70
74
  }
71
75
  if (cs.display === "none") {
72
- if (debug)
73
- console.log("+++ reject: display none", el);
74
- return false;
76
+ if (debug)
77
+ console.log("+++ reject: display none", el);
78
+ return false;
75
79
  }
76
80
  if (el.shadowRoot) {
77
- if (debug)
78
- console.log("+++ reject: shadowRoot", el);
79
- return false;
81
+ if (debug)
82
+ console.log("+++ reject: shadowRoot", el);
83
+ return false;
80
84
  }
81
85
  if (debug)
82
- console.log("+++ match", el);
86
+ console.log("+++ match", el);
83
87
  return true;
84
- }
85
- function scanElement(el, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn) {
88
+ }
89
+ function scanElement(el, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn) {
86
90
  var _a;
87
91
  if (el instanceof HTMLDivElement && el.matches(TARGET_SELECTOR)) {
88
- if (seen.indexOf(el) === -1 && looksLikeTargetDiv(el, zNearMax, uuidGate, debug)) {
89
- seen.push(el);
90
- if (removeHoney && el.parentNode)
91
- el.parentNode.removeChild(el);
92
- if (removeHoney) {
93
- onMatch(warn);
94
- }
95
- else {
96
- onMatch(warn, el);
97
- }
92
+ if (seen.indexOf(el) === -1 && looksLikeTargetDiv(el, zNearMax, uuidGate, debug)) {
93
+ seen.push(el);
94
+ if (removeHoney && el.parentNode)
95
+ el.parentNode.removeChild(el);
96
+ if (removeHoney) {
97
+ onMatch(warn);
98
+ } else {
99
+ onMatch(warn, el);
98
100
  }
101
+ }
99
102
  }
100
103
  var divs = (_a = el.querySelectorAll) === null || _a === void 0 ? void 0 : _a.call(el, TARGET_SELECTOR);
101
104
  if (!divs)
102
- return;
105
+ return;
103
106
  for (var i = 0; i < divs.length; i += 1) {
104
- var d = divs[i];
105
- if (seen.indexOf(d) === -1 && looksLikeTargetDiv(d, zNearMax, uuidGate, debug)) {
106
- seen.push(d);
107
- if (removeHoney && d.parentNode)
108
- d.parentNode.removeChild(d);
109
- if (removeHoney) {
110
- onMatch(warn);
111
- }
112
- else {
113
- onMatch(warn, d);
114
- }
107
+ var d = divs[i];
108
+ if (seen.indexOf(d) === -1 && looksLikeTargetDiv(d, zNearMax, uuidGate, debug)) {
109
+ seen.push(d);
110
+ if (removeHoney && d.parentNode)
111
+ d.parentNode.removeChild(d);
112
+ if (removeHoney) {
113
+ onMatch(warn);
114
+ } else {
115
+ onMatch(warn, d);
115
116
  }
117
+ }
116
118
  }
117
- }
118
- function startHoneyOverlayObserver(options) {
119
+ }
120
+ function startHoneyOverlayObserver(options) {
119
121
  var _a, _b, _c, _d, _e;
120
- if (options === void 0) { options = {}; }
122
+ if (options === void 0) {
123
+ options = {};
124
+ }
121
125
  var seen = [];
122
126
  var zNearMax = (_a = options.zNearMax) !== null && _a !== void 0 ? _a : DEFAULT_Z_NEAR_MAX;
123
127
  var uuidGate = (_b = options.uuidGate) !== null && _b !== void 0 ? _b : true;
124
128
  var debug = (_c = options.debug) !== null && _c !== void 0 ? _c : false;
125
129
  var removeHoney = (_d = options.removeHoney) !== null && _d !== void 0 ? _d : true;
126
- var warn = function (message) { return showOverlay(message); };
127
- var onMatch = (_e = options.onMatch) !== null && _e !== void 0 ? _e : (function () { });
128
- var mo = new MutationObserver(function (mutations) {
129
- for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
130
- var m = mutations_1[_i];
131
- if (debug &&
132
- document.body &&
133
- (m.target === document.body || (m.target instanceof Node && document.body.contains(m.target)))) {
134
- console.log("+++ body mutation", m.type, m.target);
135
- }
130
+ var warn = function(message) {
131
+ return showOverlay(message);
132
+ };
133
+ var onMatch = (_e = options.onMatch) !== null && _e !== void 0 ? _e : (function() {
134
+ });
135
+ var mo = new MutationObserver(function(mutations) {
136
+ for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
137
+ var m = mutations_1[_i];
138
+ if (debug && document.body && (m.target === document.body || m.target instanceof Node && document.body.contains(m.target))) {
139
+ console.log("+++ body mutation", m.type, m.target);
136
140
  }
137
- for (var _a = 0, mutations_2 = mutations; _a < mutations_2.length; _a++) {
138
- var m = mutations_2[_a];
139
- if (m.type === "childList") {
140
- if (m.addedNodes.length) {
141
- for (var i = 0; i < m.addedNodes.length; i += 1) {
142
- var node = m.addedNodes[i];
143
- if (node.nodeType === Node.ELEMENT_NODE) {
144
- scanElement(node, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
145
- }
146
- }
147
- }
148
- if (m.target instanceof Element) {
149
- scanElement(m.target, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
150
- }
151
- }
152
- else if (m.type === "attributes") {
153
- if (m.target instanceof Element) {
154
- scanElement(m.target, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
155
- }
141
+ }
142
+ for (var _a2 = 0, mutations_2 = mutations; _a2 < mutations_2.length; _a2++) {
143
+ var m = mutations_2[_a2];
144
+ if (m.type === "childList") {
145
+ if (m.addedNodes.length) {
146
+ for (var i = 0; i < m.addedNodes.length; i += 1) {
147
+ var node = m.addedNodes[i];
148
+ if (node.nodeType === Node.ELEMENT_NODE) {
149
+ scanElement(node, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
150
+ }
156
151
  }
152
+ }
153
+ if (m.target instanceof Element) {
154
+ scanElement(m.target, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
155
+ }
156
+ } else if (m.type === "attributes") {
157
+ if (m.target instanceof Element) {
158
+ scanElement(m.target, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
159
+ }
157
160
  }
161
+ }
158
162
  });
159
163
  mo.observe(document.documentElement, {
160
- subtree: true,
161
- childList: true,
162
- attributes: true,
163
- attributeFilter: ["style", "class", "id"]
164
+ subtree: true,
165
+ childList: true,
166
+ attributes: true,
167
+ attributeFilter: ["style", "class", "id"]
164
168
  });
165
169
  scanElement(document.documentElement, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
166
170
  return {
167
- stop: function () { return mo.disconnect(); }
171
+ stop: function() {
172
+ return mo.disconnect();
173
+ }
168
174
  };
169
- }
170
- function listen(onMatch, options) {
171
- if (options === void 0) { options = {}; }
175
+ }
176
+ function listen(onMatch, options) {
177
+ if (options === void 0) {
178
+ options = {};
179
+ }
172
180
  return startHoneyOverlayObserver(__assign(__assign({}, options), { onMatch: onMatch }));
173
- }
174
- if (typeof window !== "undefined") {
181
+ }
182
+
183
+ // dist/bundle-tmp/global.js
184
+ if (typeof window !== "undefined") {
175
185
  window.fckHoney = window.fckHoney || {};
176
186
  window.fckHoney.startHoneyOverlayObserver = startHoneyOverlayObserver;
177
187
  window.fckHoney.listen = listen;
178
- }
188
+ window.fckHoney.version = version;
189
+ }
190
+ })();
@@ -0,0 +1,18 @@
1
+ export declare const version = "0.3.1";
2
+ export type WarnCallback = (message: string) => () => void;
3
+ export type MatchCallback = (warn: WarnCallback, el?: HTMLDivElement) => void;
4
+ export interface ObserverOptions {
5
+ onMatch?: MatchCallback;
6
+ uuidGate?: boolean;
7
+ zNearMax?: number;
8
+ debug?: boolean;
9
+ removeHoney?: boolean;
10
+ }
11
+ export interface ObserverHandle {
12
+ stop: () => void;
13
+ }
14
+ export interface ListenHandle {
15
+ stop: () => void;
16
+ }
17
+ export declare function startHoneyOverlayObserver(options?: ObserverOptions): ObserverHandle;
18
+ export declare function listen(onMatch: MatchCallback, options?: Omit<ObserverOptions, "onMatch">): ListenHandle;
@@ -1,17 +1 @@
1
- export type WarnCallback = (message: string) => () => void;
2
- export type MatchCallback = (warn: WarnCallback, el?: HTMLDivElement) => void;
3
- export interface ObserverOptions {
4
- onMatch?: MatchCallback;
5
- uuidGate?: boolean;
6
- zNearMax?: number;
7
- debug?: boolean;
8
- removeHoney?: boolean;
9
- }
10
- export interface ObserverHandle {
11
- stop: () => void;
12
- }
13
- export interface ListenHandle {
14
- stop: () => void;
15
- }
16
- export declare function startHoneyOverlayObserver(options?: ObserverOptions): ObserverHandle;
17
- export declare function listen(onMatch: MatchCallback, options?: Omit<ObserverOptions, "onMatch">): ListenHandle;
1
+ export * from "./core";
@@ -0,0 +1 @@
1
+ export declare const VERSION = "0.3.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fck-honey",
3
- "version": "0.2.2",
3
+ "version": "0.3.1",
4
4
  "description": "Detects Honey browser extension overlays for merchants.",
5
5
  "license": "MIT",
6
6
  "main": "dist/honey-detect.js",
@@ -17,11 +17,13 @@
17
17
  "dist"
18
18
  ],
19
19
  "scripts": {
20
- "build": "tsc -p tsconfig.esm.json && tsc -p tsconfig.global.json",
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
22
  "prepublishOnly": "npm run build",
22
23
  "clean": "rm -rf dist"
23
24
  },
24
25
  "devDependencies": {
26
+ "esbuild": "^0.25.12",
25
27
  "typescript": "^5.9.3"
26
28
  }
27
29
  }