fck-honey 0.2.2 → 0.3.0

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)
@@ -0,0 +1,172 @@
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
+ }
@@ -0,0 +1,6 @@
1
+ import { listen, startHoneyOverlayObserver } from "./core";
2
+ if (typeof window !== "undefined") {
3
+ window.fckHoney = window.fckHoney || {};
4
+ window.fckHoney.startHoneyOverlayObserver = startHoneyOverlayObserver;
5
+ window.fckHoney.listen = listen;
6
+ }
@@ -0,0 +1,172 @@
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
+ }
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";
@@ -1,29 +1,29 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
1
+ (function() {
2
+ // dist/bundle-tmp/core.js
3
+ var __assign = function() {
3
4
  __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;
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
+ t[p] = s[p];
9
+ }
10
+ return t;
10
11
  };
11
12
  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) {
13
+ };
14
+ var DEFAULT_Z_NEAR_MAX = 214748e4;
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) {
18
19
  if (typeof document === "undefined")
19
- return function () { };
20
+ return function() {
21
+ };
20
22
  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);
23
+ var style = document.createElement("style");
24
+ style.id = OVERLAY_STYLE_ID;
25
+ 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);}";
26
+ document.head.appendChild(style);
27
27
  }
28
28
  var overlay = document.createElement("div");
29
29
  overlay.className = "simple-overlay";
@@ -32,147 +32,154 @@ function showOverlay(message) {
32
32
  messageEl.innerHTML = message;
33
33
  overlay.appendChild(messageEl);
34
34
  if (document.body) {
35
- document.body.appendChild(overlay);
35
+ document.body.appendChild(overlay);
36
36
  }
37
37
  var prevOverflow = document.body ? document.body.style.overflow : "";
38
38
  if (document.body)
39
- document.body.style.overflow = "hidden";
39
+ document.body.style.overflow = "hidden";
40
40
  return function hideOverlay() {
41
- overlay.remove();
42
- if (document.body)
43
- document.body.style.overflow = prevOverflow;
41
+ overlay.remove();
42
+ if (document.body)
43
+ document.body.style.overflow = prevOverflow;
44
44
  };
45
- }
46
- function parseZIndex(cs, el) {
45
+ }
46
+ function parseZIndex(cs, el) {
47
47
  var computed = parseInt(cs.zIndex, 10);
48
48
  if (isFinite(computed))
49
- return computed;
49
+ return computed;
50
50
  var inline = parseInt(el.style.zIndex, 10);
51
51
  return isFinite(inline) ? inline : null;
52
- }
53
- function looksLikeTargetDiv(el, zNearMax, uuidGate, debug) {
52
+ }
53
+ function looksLikeTargetDiv(el, zNearMax, uuidGate, debug) {
54
54
  if (!el.id) {
55
- if (debug)
56
- console.log("+++ reject: no id", el);
57
- return false;
55
+ if (debug)
56
+ console.log("+++ reject: no id", el);
57
+ return false;
58
58
  }
59
59
  if (uuidGate && !UUIDISH_RE.test(el.id)) {
60
- if (debug)
61
- console.log("+++ reject: uuid", el.id);
62
- return false;
60
+ if (debug)
61
+ console.log("+++ reject: uuid", el.id);
62
+ return false;
63
63
  }
64
64
  var cs = getComputedStyle(el);
65
65
  var z = parseZIndex(cs, el);
66
66
  if (z === null || z < zNearMax) {
67
- if (debug)
68
- console.log("+++ reject: z-index", z, cs.zIndex, el.style.zIndex, el);
69
- return false;
67
+ if (debug)
68
+ console.log("+++ reject: z-index", z, cs.zIndex, el.style.zIndex, el);
69
+ return false;
70
70
  }
71
71
  if (cs.display === "none") {
72
- if (debug)
73
- console.log("+++ reject: display none", el);
74
- return false;
72
+ if (debug)
73
+ console.log("+++ reject: display none", el);
74
+ return false;
75
75
  }
76
76
  if (el.shadowRoot) {
77
- if (debug)
78
- console.log("+++ reject: shadowRoot", el);
79
- return false;
77
+ if (debug)
78
+ console.log("+++ reject: shadowRoot", el);
79
+ return false;
80
80
  }
81
81
  if (debug)
82
- console.log("+++ match", el);
82
+ console.log("+++ match", el);
83
83
  return true;
84
- }
85
- function scanElement(el, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn) {
84
+ }
85
+ function scanElement(el, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn) {
86
86
  var _a;
87
87
  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
- }
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
+ } else {
95
+ onMatch(warn, el);
98
96
  }
97
+ }
99
98
  }
100
99
  var divs = (_a = el.querySelectorAll) === null || _a === void 0 ? void 0 : _a.call(el, TARGET_SELECTOR);
101
100
  if (!divs)
102
- return;
101
+ return;
103
102
  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
- }
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
+ } else {
111
+ onMatch(warn, d);
115
112
  }
113
+ }
116
114
  }
117
- }
118
- function startHoneyOverlayObserver(options) {
115
+ }
116
+ function startHoneyOverlayObserver(options) {
119
117
  var _a, _b, _c, _d, _e;
120
- if (options === void 0) { options = {}; }
118
+ if (options === void 0) {
119
+ options = {};
120
+ }
121
121
  var seen = [];
122
122
  var zNearMax = (_a = options.zNearMax) !== null && _a !== void 0 ? _a : DEFAULT_Z_NEAR_MAX;
123
123
  var uuidGate = (_b = options.uuidGate) !== null && _b !== void 0 ? _b : true;
124
124
  var debug = (_c = options.debug) !== null && _c !== void 0 ? _c : false;
125
125
  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
- }
126
+ var warn = function(message) {
127
+ return showOverlay(message);
128
+ };
129
+ var onMatch = (_e = options.onMatch) !== null && _e !== void 0 ? _e : (function() {
130
+ });
131
+ var mo = new MutationObserver(function(mutations) {
132
+ for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
133
+ var m = mutations_1[_i];
134
+ if (debug && document.body && (m.target === document.body || m.target instanceof Node && document.body.contains(m.target))) {
135
+ console.log("+++ body mutation", m.type, m.target);
136
136
  }
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
- }
137
+ }
138
+ for (var _a2 = 0, mutations_2 = mutations; _a2 < mutations_2.length; _a2++) {
139
+ var m = mutations_2[_a2];
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
+ }
156
147
  }
148
+ }
149
+ if (m.target instanceof Element) {
150
+ scanElement(m.target, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
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
+ }
157
156
  }
157
+ }
158
158
  });
159
159
  mo.observe(document.documentElement, {
160
- subtree: true,
161
- childList: true,
162
- attributes: true,
163
- attributeFilter: ["style", "class", "id"]
160
+ subtree: true,
161
+ childList: true,
162
+ attributes: true,
163
+ attributeFilter: ["style", "class", "id"]
164
164
  });
165
165
  scanElement(document.documentElement, seen, zNearMax, uuidGate, debug, removeHoney, onMatch, warn);
166
166
  return {
167
- stop: function () { return mo.disconnect(); }
167
+ stop: function() {
168
+ return mo.disconnect();
169
+ }
168
170
  };
169
- }
170
- function listen(onMatch, options) {
171
- if (options === void 0) { options = {}; }
171
+ }
172
+ function listen(onMatch, options) {
173
+ if (options === void 0) {
174
+ options = {};
175
+ }
172
176
  return startHoneyOverlayObserver(__assign(__assign({}, options), { onMatch: onMatch }));
173
- }
174
- if (typeof window !== "undefined") {
177
+ }
178
+
179
+ // dist/bundle-tmp/global.js
180
+ if (typeof window !== "undefined") {
175
181
  window.fckHoney = window.fckHoney || {};
176
182
  window.fckHoney.startHoneyOverlayObserver = startHoneyOverlayObserver;
177
183
  window.fckHoney.listen = listen;
178
- }
184
+ }
185
+ })();
@@ -0,0 +1,17 @@
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,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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fck-honey",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Detects Honey browser extension overlays for merchants.",
5
5
  "license": "MIT",
6
6
  "main": "dist/honey-detect.js",
@@ -17,11 +17,12 @@
17
17
  "dist"
18
18
  ],
19
19
  "scripts": {
20
- "build": "tsc -p tsconfig.esm.json && tsc -p tsconfig.global.json",
20
+ "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
21
  "prepublishOnly": "npm run build",
22
22
  "clean": "rm -rf dist"
23
23
  },
24
24
  "devDependencies": {
25
+ "esbuild": "^0.25.12",
25
26
  "typescript": "^5.9.3"
26
27
  }
27
28
  }