fck-honey 0.1.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/LICENSE +21 -0
- package/dist/honey-detect.d.ts +22 -0
- package/dist/honey-detect.js +109 -0
- package/dist/index.js +115 -0
- package/dist/types/index.d.ts +22 -0
- package/package.json +20 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Cooper Reid
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare namespace fckHoney {
|
|
2
|
+
type MatchCallback = (el: HTMLDivElement) => void;
|
|
3
|
+
interface ObserverOptions {
|
|
4
|
+
onMatch?: MatchCallback;
|
|
5
|
+
uuidGate?: boolean;
|
|
6
|
+
zNearMax?: number;
|
|
7
|
+
}
|
|
8
|
+
interface ObserverHandle {
|
|
9
|
+
stop: () => void;
|
|
10
|
+
}
|
|
11
|
+
interface ListenHandle {
|
|
12
|
+
stop: () => void;
|
|
13
|
+
}
|
|
14
|
+
function startHoneyOverlayObserver(options?: ObserverOptions): ObserverHandle;
|
|
15
|
+
function listen(onMatch: MatchCallback, options?: Omit<ObserverOptions, "onMatch">): ListenHandle;
|
|
16
|
+
}
|
|
17
|
+
interface Window {
|
|
18
|
+
fckHoney?: {
|
|
19
|
+
startHoneyOverlayObserver?: typeof fckHoney.startHoneyOverlayObserver;
|
|
20
|
+
listen?: typeof fckHoney.listen;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__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;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var fckHoney;
|
|
14
|
+
(function (fckHoney) {
|
|
15
|
+
var DEFAULT_Z_NEAR_MAX = 2147480000;
|
|
16
|
+
var UUIDISH_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
17
|
+
function parseZIndex(cs) {
|
|
18
|
+
var z = parseInt(cs.zIndex, 10);
|
|
19
|
+
return isFinite(z) ? z : null;
|
|
20
|
+
}
|
|
21
|
+
function looksLikeTargetDiv(el, zNearMax, uuidGate) {
|
|
22
|
+
if (!el.id)
|
|
23
|
+
return false;
|
|
24
|
+
if (uuidGate && !UUIDISH_RE.test(el.id))
|
|
25
|
+
return false;
|
|
26
|
+
var cs = getComputedStyle(el);
|
|
27
|
+
var z = parseZIndex(cs);
|
|
28
|
+
if (z === null || z < zNearMax)
|
|
29
|
+
return false;
|
|
30
|
+
if (cs.display === "none")
|
|
31
|
+
return false;
|
|
32
|
+
if (el.shadowRoot)
|
|
33
|
+
return false;
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
function checkNode(node, seen, zNearMax, uuidGate, onMatch) {
|
|
37
|
+
var _a;
|
|
38
|
+
if (!(node instanceof Element))
|
|
39
|
+
return;
|
|
40
|
+
if (node instanceof HTMLDivElement &&
|
|
41
|
+
seen.indexOf(node) === -1 &&
|
|
42
|
+
looksLikeTargetDiv(node, zNearMax, uuidGate)) {
|
|
43
|
+
seen.push(node);
|
|
44
|
+
onMatch(node);
|
|
45
|
+
}
|
|
46
|
+
var divs = (_a = node.querySelectorAll) === null || _a === void 0 ? void 0 : _a.call(node, "div[id]");
|
|
47
|
+
if (!divs)
|
|
48
|
+
return;
|
|
49
|
+
for (var i = 0; i < divs.length; i += 1) {
|
|
50
|
+
var d = divs[i];
|
|
51
|
+
if (seen.indexOf(d) === -1 && looksLikeTargetDiv(d, zNearMax, uuidGate)) {
|
|
52
|
+
seen.push(d);
|
|
53
|
+
onMatch(d);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function startHoneyOverlayObserver(options) {
|
|
58
|
+
var _a, _b, _c;
|
|
59
|
+
if (options === void 0) { options = {}; }
|
|
60
|
+
var seen = [];
|
|
61
|
+
var zNearMax = (_a = options.zNearMax) !== null && _a !== void 0 ? _a : DEFAULT_Z_NEAR_MAX;
|
|
62
|
+
var uuidGate = (_b = options.uuidGate) !== null && _b !== void 0 ? _b : true;
|
|
63
|
+
var onMatch = (_c = options.onMatch) !== null && _c !== void 0 ? _c : (function (el) {
|
|
64
|
+
// Default: warn only, leaving response up to caller.
|
|
65
|
+
console.warn("[honey-detect] matched near-max z-index div:", el);
|
|
66
|
+
});
|
|
67
|
+
var mo = new MutationObserver(function (mutations) {
|
|
68
|
+
for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
|
|
69
|
+
var m = mutations_1[_i];
|
|
70
|
+
if (m.type === "childList") {
|
|
71
|
+
for (var i = 0; i < m.addedNodes.length; i += 1) {
|
|
72
|
+
checkNode(m.addedNodes[i], seen, zNearMax, uuidGate, onMatch);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (m.type === "attributes") {
|
|
76
|
+
var el = m.target;
|
|
77
|
+
if (el instanceof HTMLDivElement &&
|
|
78
|
+
el.id &&
|
|
79
|
+
seen.indexOf(el) === -1 &&
|
|
80
|
+
looksLikeTargetDiv(el, zNearMax, uuidGate)) {
|
|
81
|
+
seen.push(el);
|
|
82
|
+
onMatch(el);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
mo.observe(document.documentElement, {
|
|
88
|
+
subtree: true,
|
|
89
|
+
childList: true,
|
|
90
|
+
attributes: true,
|
|
91
|
+
attributeFilter: ["style", "class", "id"]
|
|
92
|
+
});
|
|
93
|
+
checkNode(document.documentElement, seen, zNearMax, uuidGate, onMatch);
|
|
94
|
+
return {
|
|
95
|
+
stop: function () { return mo.disconnect(); }
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
fckHoney.startHoneyOverlayObserver = startHoneyOverlayObserver;
|
|
99
|
+
function listen(onMatch, options) {
|
|
100
|
+
if (options === void 0) { options = {}; }
|
|
101
|
+
return startHoneyOverlayObserver(__assign(__assign({}, options), { onMatch: onMatch }));
|
|
102
|
+
}
|
|
103
|
+
fckHoney.listen = listen;
|
|
104
|
+
})(fckHoney || (fckHoney = {}));
|
|
105
|
+
if (typeof window !== "undefined") {
|
|
106
|
+
window.fckHoney = window.fckHoney || {};
|
|
107
|
+
window.fckHoney.startHoneyOverlayObserver = fckHoney.startHoneyOverlayObserver;
|
|
108
|
+
window.fckHoney.listen = fckHoney.listen;
|
|
109
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
(function (factory) {
|
|
13
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
14
|
+
var v = factory(require, exports);
|
|
15
|
+
if (v !== undefined) module.exports = v;
|
|
16
|
+
}
|
|
17
|
+
else if (typeof define === "function" && define.amd) {
|
|
18
|
+
define(["require", "exports"], factory);
|
|
19
|
+
}
|
|
20
|
+
})(function (require, exports) {
|
|
21
|
+
"use strict";
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.startHoneyOverlayObserver = startHoneyOverlayObserver;
|
|
24
|
+
exports.listen = listen;
|
|
25
|
+
var DEFAULT_Z_NEAR_MAX = 2147480000;
|
|
26
|
+
var UUIDISH_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
27
|
+
function parseZIndex(cs) {
|
|
28
|
+
var z = parseInt(cs.zIndex, 10);
|
|
29
|
+
return isFinite(z) ? z : null;
|
|
30
|
+
}
|
|
31
|
+
function looksLikeTargetDiv(el, zNearMax, uuidGate) {
|
|
32
|
+
if (!el.id)
|
|
33
|
+
return false;
|
|
34
|
+
if (uuidGate && !UUIDISH_RE.test(el.id))
|
|
35
|
+
return false;
|
|
36
|
+
var cs = getComputedStyle(el);
|
|
37
|
+
var z = parseZIndex(cs);
|
|
38
|
+
if (z === null || z < zNearMax)
|
|
39
|
+
return false;
|
|
40
|
+
if (cs.display === "none")
|
|
41
|
+
return false;
|
|
42
|
+
if (el.shadowRoot)
|
|
43
|
+
return false;
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
function checkNode(node, seen, zNearMax, uuidGate, onMatch) {
|
|
47
|
+
var _a;
|
|
48
|
+
if (!(node instanceof Element))
|
|
49
|
+
return;
|
|
50
|
+
if (node instanceof HTMLDivElement && seen.indexOf(node) === -1 && looksLikeTargetDiv(node, zNearMax, uuidGate)) {
|
|
51
|
+
seen.push(node);
|
|
52
|
+
onMatch(node);
|
|
53
|
+
}
|
|
54
|
+
var divs = (_a = node.querySelectorAll) === null || _a === void 0 ? void 0 : _a.call(node, "div[id]");
|
|
55
|
+
if (!divs)
|
|
56
|
+
return;
|
|
57
|
+
for (var i = 0; i < divs.length; i += 1) {
|
|
58
|
+
var d = divs[i];
|
|
59
|
+
if (seen.indexOf(d) === -1 && looksLikeTargetDiv(d, zNearMax, uuidGate)) {
|
|
60
|
+
seen.push(d);
|
|
61
|
+
onMatch(d);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function startHoneyOverlayObserver(options) {
|
|
66
|
+
var _a, _b, _c;
|
|
67
|
+
if (options === void 0) { options = {}; }
|
|
68
|
+
var seen = [];
|
|
69
|
+
var zNearMax = (_a = options.zNearMax) !== null && _a !== void 0 ? _a : DEFAULT_Z_NEAR_MAX;
|
|
70
|
+
var uuidGate = (_b = options.uuidGate) !== null && _b !== void 0 ? _b : true;
|
|
71
|
+
var onMatch = (_c = options.onMatch) !== null && _c !== void 0 ? _c : (function (el) {
|
|
72
|
+
// Default: warn only, leaving response up to caller.
|
|
73
|
+
console.warn("[honey-detect] matched near-max z-index div:", el);
|
|
74
|
+
});
|
|
75
|
+
var mo = new MutationObserver(function (mutations) {
|
|
76
|
+
for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
|
|
77
|
+
var m = mutations_1[_i];
|
|
78
|
+
if (m.type === "childList") {
|
|
79
|
+
for (var i = 0; i < m.addedNodes.length; i += 1) {
|
|
80
|
+
checkNode(m.addedNodes[i], seen, zNearMax, uuidGate, onMatch);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else if (m.type === "attributes") {
|
|
84
|
+
var el = m.target;
|
|
85
|
+
if (el instanceof HTMLDivElement &&
|
|
86
|
+
el.id &&
|
|
87
|
+
seen.indexOf(el) === -1 &&
|
|
88
|
+
looksLikeTargetDiv(el, zNearMax, uuidGate)) {
|
|
89
|
+
seen.push(el);
|
|
90
|
+
onMatch(el);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
mo.observe(document.documentElement, {
|
|
96
|
+
subtree: true,
|
|
97
|
+
childList: true,
|
|
98
|
+
attributes: true,
|
|
99
|
+
attributeFilter: ["style", "class", "id"]
|
|
100
|
+
});
|
|
101
|
+
checkNode(document.documentElement, seen, zNearMax, uuidGate, onMatch);
|
|
102
|
+
return {
|
|
103
|
+
stop: function () { return mo.disconnect(); }
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function listen(onMatch, options) {
|
|
107
|
+
if (options === void 0) { options = {}; }
|
|
108
|
+
return startHoneyOverlayObserver(__assign(__assign({}, options), { onMatch: onMatch }));
|
|
109
|
+
}
|
|
110
|
+
if (typeof window !== "undefined") {
|
|
111
|
+
window.fckHoney = window.fckHoney || {};
|
|
112
|
+
window.fckHoney.startHoneyOverlayObserver = startHoneyOverlayObserver;
|
|
113
|
+
window.fckHoney.listen = listen;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type MatchCallback = (el: HTMLDivElement) => void;
|
|
2
|
+
export interface ObserverOptions {
|
|
3
|
+
onMatch?: MatchCallback;
|
|
4
|
+
uuidGate?: boolean;
|
|
5
|
+
zNearMax?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ObserverHandle {
|
|
8
|
+
stop: () => void;
|
|
9
|
+
}
|
|
10
|
+
export interface ListenHandle {
|
|
11
|
+
stop: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function startHoneyOverlayObserver(options?: ObserverOptions): ObserverHandle;
|
|
14
|
+
export declare function listen(onMatch: MatchCallback, options?: Omit<ObserverOptions, "onMatch">): ListenHandle;
|
|
15
|
+
declare global {
|
|
16
|
+
interface Window {
|
|
17
|
+
fckHoney?: {
|
|
18
|
+
startHoneyOverlayObserver?: typeof startHoneyOverlayObserver;
|
|
19
|
+
listen?: typeof listen;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "fck-honey",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Detects Honey browser extension overlays for merchants.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/honey-detect.js",
|
|
7
|
+
"types": "dist/honey-detect.d.ts",
|
|
8
|
+
"jsdelivr": "dist/honey-detect.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc -p tsconfig.json",
|
|
14
|
+
"prepublishOnly": "npm run build",
|
|
15
|
+
"clean": "rm -rf dist"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.9.3"
|
|
19
|
+
}
|
|
20
|
+
}
|