coupon-shield 0.3.11
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/README.md +62 -0
- package/dist/auto.js +305 -0
- package/dist/bundle-tmp/auto.js +28 -0
- package/dist/bundle-tmp/core.js +286 -0
- package/dist/bundle-tmp/global.js +6 -0
- package/dist/bundle-tmp/version.js +2 -0
- package/dist/couponshield.js +295 -0
- package/dist/esm/core.js +286 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/version.js +2 -0
- package/dist/honey-detect.d.ts +22 -0
- package/dist/honey-detect.js +295 -0
- package/dist/index.js +115 -0
- package/dist/types/core.d.ts +20 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/version.d.ts +1 -0
- package/package.json +29 -0
|
@@ -0,0 +1,286 @@
|
|
|
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";
|
|
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:2147483647;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 getDataGuidAttribute(el) {
|
|
55
|
+
for (var i = 0; i < el.attributes.length; i += 1) {
|
|
56
|
+
var attr = el.attributes[i];
|
|
57
|
+
if (!attr)
|
|
58
|
+
continue;
|
|
59
|
+
if (attr.name.indexOf("data-") === 0) {
|
|
60
|
+
var suffix = attr.name.slice(5);
|
|
61
|
+
if (UUIDISH_RE.test(suffix) && attr.value === "true") {
|
|
62
|
+
return attr.name;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
function hasNearMaxZIndex(el, zNearMax, debug) {
|
|
69
|
+
// Fast path: if inline z-index is missing or below threshold, skip expensive getComputedStyle
|
|
70
|
+
var inlineZ = parseInt(el.style.zIndex, 10);
|
|
71
|
+
if (!isFinite(inlineZ) || inlineZ < zNearMax) {
|
|
72
|
+
var cs_1 = getComputedStyle(el);
|
|
73
|
+
var z_1 = parseZIndex(cs_1, el);
|
|
74
|
+
if (z_1 === null || z_1 < zNearMax) {
|
|
75
|
+
if (debug)
|
|
76
|
+
console.log("+++ reject: z-index", z_1, cs_1.zIndex, el.style.zIndex, el);
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (cs_1.display === "none") {
|
|
80
|
+
if (debug)
|
|
81
|
+
console.log("+++ reject: display none", el);
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
var cs = getComputedStyle(el);
|
|
87
|
+
var z = parseZIndex(cs, el);
|
|
88
|
+
if (z === null || z < zNearMax) {
|
|
89
|
+
if (debug)
|
|
90
|
+
console.log("+++ reject: z-index", z, cs.zIndex, el.style.zIndex, el);
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
if (cs.display === "none") {
|
|
94
|
+
if (debug)
|
|
95
|
+
console.log("+++ reject: display none", el);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
// Each matcher should only check vendor-specific flags; shared z-index gating happens earlier.
|
|
101
|
+
var VENDOR_MATCHERS = [
|
|
102
|
+
{
|
|
103
|
+
name: "honey",
|
|
104
|
+
matches: function (el, zNearMax, uuidGate, debug) {
|
|
105
|
+
if (!hasNearMaxZIndex(el, zNearMax, debug))
|
|
106
|
+
return false;
|
|
107
|
+
if (!el.id) {
|
|
108
|
+
if (debug)
|
|
109
|
+
console.log("+++ reject: no id", el);
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
if (uuidGate && !UUIDISH_RE.test(el.id)) {
|
|
113
|
+
if (debug)
|
|
114
|
+
console.log("+++ reject: uuid", el.id);
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
if (el.shadowRoot) {
|
|
118
|
+
if (debug)
|
|
119
|
+
console.log("+++ reject: shadowRoot", el);
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "Capital One Shopping",
|
|
127
|
+
matches: function (el, zNearMax, _uuidGate, debug) {
|
|
128
|
+
if (!hasNearMaxZIndex(el, zNearMax, debug))
|
|
129
|
+
return false;
|
|
130
|
+
var dataGuid = getDataGuidAttribute(el);
|
|
131
|
+
if (!dataGuid) {
|
|
132
|
+
if (debug)
|
|
133
|
+
console.log("+++ reject: no data guid", el);
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
if (el.shadowRoot) {
|
|
137
|
+
if (debug)
|
|
138
|
+
console.log("+++ reject: shadowRoot", el);
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
if (debug)
|
|
142
|
+
console.log("+++ match capitalone", dataGuid, el);
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "Rakuten",
|
|
148
|
+
matches: function (el, _zNearMax, _uuidGate, debug) {
|
|
149
|
+
if (!el.shadowRoot) {
|
|
150
|
+
if (debug)
|
|
151
|
+
console.log("+++ reject: no shadowRoot", el);
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
var style = el.shadowRoot.querySelector("style#rr-style-content");
|
|
155
|
+
if (!style) {
|
|
156
|
+
if (debug)
|
|
157
|
+
console.log("+++ reject: no rr-style-content", el);
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
];
|
|
164
|
+
function getVendorForDiv(el, zNearMax, uuidGate, debug) {
|
|
165
|
+
for (var i = 0; i < VENDOR_MATCHERS.length; i += 1) {
|
|
166
|
+
var matcher = VENDOR_MATCHERS[i];
|
|
167
|
+
if (matcher.matches(el, zNearMax, uuidGate, debug)) {
|
|
168
|
+
if (debug)
|
|
169
|
+
console.log("+++ match", matcher.name, el);
|
|
170
|
+
return matcher.name;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (debug)
|
|
174
|
+
console.log("+++ reject: no vendor match", el);
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
function scanElement(el, seen, zNearMax, uuidGate, debug, handleMatch) {
|
|
178
|
+
var _a;
|
|
179
|
+
if (el instanceof HTMLDivElement && el.matches(TARGET_SELECTOR)) {
|
|
180
|
+
var vendor = getVendorForDiv(el, zNearMax, uuidGate, debug);
|
|
181
|
+
if (seen.indexOf(el) === -1 && vendor) {
|
|
182
|
+
seen.push(el);
|
|
183
|
+
handleMatch(el, vendor);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
var divs = (_a = el.querySelectorAll) === null || _a === void 0 ? void 0 : _a.call(el, TARGET_SELECTOR);
|
|
187
|
+
if (!divs)
|
|
188
|
+
return;
|
|
189
|
+
for (var i = 0; i < divs.length; i += 1) {
|
|
190
|
+
var d = divs[i];
|
|
191
|
+
var vendor = getVendorForDiv(d, zNearMax, uuidGate, debug);
|
|
192
|
+
if (seen.indexOf(d) === -1 && vendor) {
|
|
193
|
+
seen.push(d);
|
|
194
|
+
handleMatch(d, vendor);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
export function startHoneyOverlayObserver(options) {
|
|
199
|
+
var _a, _b, _c, _d, _e;
|
|
200
|
+
if (options === void 0) { options = {}; }
|
|
201
|
+
var seen = [];
|
|
202
|
+
var zNearMax = (_a = options.zNearMax) !== null && _a !== void 0 ? _a : DEFAULT_Z_NEAR_MAX;
|
|
203
|
+
var uuidGate = (_b = options.uuidGate) !== null && _b !== void 0 ? _b : true;
|
|
204
|
+
var debug = (_c = options.debug) !== null && _c !== void 0 ? _c : false;
|
|
205
|
+
var removeHoney = (_d = options.removeHoney) !== null && _d !== void 0 ? _d : true;
|
|
206
|
+
var unbindAfterSeconds = options.unbindAfterSeconds;
|
|
207
|
+
var warn = function (message) { return showOverlay(message); };
|
|
208
|
+
var onMatch = (_e = options.onMatch) !== null && _e !== void 0 ? _e : (function () { });
|
|
209
|
+
var matched = false;
|
|
210
|
+
var unbindTimer;
|
|
211
|
+
var handleMatch = function (el, vendor) {
|
|
212
|
+
matched = true;
|
|
213
|
+
if (typeof unbindTimer === "number") {
|
|
214
|
+
clearTimeout(unbindTimer);
|
|
215
|
+
unbindTimer = undefined;
|
|
216
|
+
}
|
|
217
|
+
if (removeHoney && el.parentNode)
|
|
218
|
+
el.parentNode.removeChild(el);
|
|
219
|
+
if (removeHoney) {
|
|
220
|
+
onMatch(warn, undefined, vendor);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
onMatch(warn, el, vendor);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
// Greedy, page-wide observer: Honey overlays can be inserted late, moved,
|
|
227
|
+
// or have z-index applied after insertion. We watch all DOM changes so we
|
|
228
|
+
// can catch the element no matter when it appears or how it's styled.
|
|
229
|
+
var mo = new MutationObserver(function (mutations) {
|
|
230
|
+
for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
|
|
231
|
+
var m = mutations_1[_i];
|
|
232
|
+
if (debug &&
|
|
233
|
+
document.body &&
|
|
234
|
+
(m.target === document.body || (m.target instanceof Node && document.body.contains(m.target)))) {
|
|
235
|
+
console.log("+++ body mutation", m.type, m.target);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
for (var _a = 0, mutations_2 = mutations; _a < mutations_2.length; _a++) {
|
|
239
|
+
var m = mutations_2[_a];
|
|
240
|
+
if (m.type === "childList") {
|
|
241
|
+
if (m.addedNodes.length) {
|
|
242
|
+
for (var i = 0; i < m.addedNodes.length; i += 1) {
|
|
243
|
+
var node = m.addedNodes[i];
|
|
244
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
245
|
+
scanElement(node, seen, zNearMax, uuidGate, debug, handleMatch);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (m.target instanceof Element) {
|
|
250
|
+
scanElement(m.target, seen, zNearMax, uuidGate, debug, handleMatch);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else if (m.type === "attributes") {
|
|
254
|
+
if (m.target instanceof Element) {
|
|
255
|
+
scanElement(m.target, seen, zNearMax, uuidGate, debug, handleMatch);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
mo.observe(document.documentElement, {
|
|
261
|
+
subtree: true,
|
|
262
|
+
childList: true,
|
|
263
|
+
attributes: true,
|
|
264
|
+
attributeFilter: ["style", "class", "id"]
|
|
265
|
+
});
|
|
266
|
+
scanElement(document.documentElement, seen, zNearMax, uuidGate, debug, handleMatch);
|
|
267
|
+
if (typeof unbindAfterSeconds === "number" && unbindAfterSeconds > 0) {
|
|
268
|
+
unbindTimer = window.setTimeout(function () {
|
|
269
|
+
if (!matched) {
|
|
270
|
+
mo.disconnect();
|
|
271
|
+
}
|
|
272
|
+
}, unbindAfterSeconds * 1000);
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
stop: function () {
|
|
276
|
+
mo.disconnect();
|
|
277
|
+
if (typeof unbindTimer === "number") {
|
|
278
|
+
clearTimeout(unbindTimer);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
export function listen(onMatch, options) {
|
|
284
|
+
if (options === void 0) { options = {}; }
|
|
285
|
+
return startHoneyOverlayObserver(__assign(__assign({}, options), { onMatch: onMatch }));
|
|
286
|
+
}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
// dist/bundle-tmp/version.js
|
|
3
|
+
var VERSION = "0.3.11";
|
|
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";
|
|
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 getDataGuidAttribute(el) {
|
|
58
|
+
for (var i = 0; i < el.attributes.length; i += 1) {
|
|
59
|
+
var attr = el.attributes[i];
|
|
60
|
+
if (!attr)
|
|
61
|
+
continue;
|
|
62
|
+
if (attr.name.indexOf("data-") === 0) {
|
|
63
|
+
var suffix = attr.name.slice(5);
|
|
64
|
+
if (UUIDISH_RE.test(suffix) && attr.value === "true") {
|
|
65
|
+
return attr.name;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
function hasNearMaxZIndex(el, zNearMax, debug) {
|
|
72
|
+
var inlineZ = parseInt(el.style.zIndex, 10);
|
|
73
|
+
if (!isFinite(inlineZ) || inlineZ < zNearMax) {
|
|
74
|
+
var cs_1 = getComputedStyle(el);
|
|
75
|
+
var z_1 = parseZIndex(cs_1, el);
|
|
76
|
+
if (z_1 === null || z_1 < zNearMax) {
|
|
77
|
+
if (debug)
|
|
78
|
+
console.log("+++ reject: z-index", z_1, cs_1.zIndex, el.style.zIndex, el);
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (cs_1.display === "none") {
|
|
82
|
+
if (debug)
|
|
83
|
+
console.log("+++ reject: display none", el);
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
var cs = getComputedStyle(el);
|
|
89
|
+
var z = parseZIndex(cs, el);
|
|
90
|
+
if (z === null || z < zNearMax) {
|
|
91
|
+
if (debug)
|
|
92
|
+
console.log("+++ reject: z-index", z, cs.zIndex, el.style.zIndex, el);
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
if (cs.display === "none") {
|
|
96
|
+
if (debug)
|
|
97
|
+
console.log("+++ reject: display none", el);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
var VENDOR_MATCHERS = [
|
|
103
|
+
{
|
|
104
|
+
name: "honey",
|
|
105
|
+
matches: function(el, zNearMax, uuidGate, debug) {
|
|
106
|
+
if (!hasNearMaxZIndex(el, zNearMax, debug))
|
|
107
|
+
return false;
|
|
108
|
+
if (!el.id) {
|
|
109
|
+
if (debug)
|
|
110
|
+
console.log("+++ reject: no id", el);
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
if (uuidGate && !UUIDISH_RE.test(el.id)) {
|
|
114
|
+
if (debug)
|
|
115
|
+
console.log("+++ reject: uuid", el.id);
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
if (el.shadowRoot) {
|
|
119
|
+
if (debug)
|
|
120
|
+
console.log("+++ reject: shadowRoot", el);
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "Capital One Shopping",
|
|
128
|
+
matches: function(el, zNearMax, _uuidGate, debug) {
|
|
129
|
+
if (!hasNearMaxZIndex(el, zNearMax, debug))
|
|
130
|
+
return false;
|
|
131
|
+
var dataGuid = getDataGuidAttribute(el);
|
|
132
|
+
if (!dataGuid) {
|
|
133
|
+
if (debug)
|
|
134
|
+
console.log("+++ reject: no data guid", el);
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
if (el.shadowRoot) {
|
|
138
|
+
if (debug)
|
|
139
|
+
console.log("+++ reject: shadowRoot", el);
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
if (debug)
|
|
143
|
+
console.log("+++ match capitalone", dataGuid, el);
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: "Rakuten",
|
|
149
|
+
matches: function(el, _zNearMax, _uuidGate, debug) {
|
|
150
|
+
if (!el.shadowRoot) {
|
|
151
|
+
if (debug)
|
|
152
|
+
console.log("+++ reject: no shadowRoot", el);
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
var style = el.shadowRoot.querySelector("style#rr-style-content");
|
|
156
|
+
if (!style) {
|
|
157
|
+
if (debug)
|
|
158
|
+
console.log("+++ reject: no rr-style-content", el);
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
];
|
|
165
|
+
function getVendorForDiv(el, zNearMax, uuidGate, debug) {
|
|
166
|
+
for (var i = 0; i < VENDOR_MATCHERS.length; i += 1) {
|
|
167
|
+
var matcher = VENDOR_MATCHERS[i];
|
|
168
|
+
if (matcher.matches(el, zNearMax, uuidGate, debug)) {
|
|
169
|
+
if (debug)
|
|
170
|
+
console.log("+++ match", matcher.name, el);
|
|
171
|
+
return matcher.name;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (debug)
|
|
175
|
+
console.log("+++ reject: no vendor match", el);
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
function scanElement(el, seen, zNearMax, uuidGate, debug, handleMatch) {
|
|
179
|
+
var _a;
|
|
180
|
+
if (el instanceof HTMLDivElement && el.matches(TARGET_SELECTOR)) {
|
|
181
|
+
var vendor = getVendorForDiv(el, zNearMax, uuidGate, debug);
|
|
182
|
+
if (seen.indexOf(el) === -1 && vendor) {
|
|
183
|
+
seen.push(el);
|
|
184
|
+
handleMatch(el, vendor);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
var divs = (_a = el.querySelectorAll) === null || _a === void 0 ? void 0 : _a.call(el, TARGET_SELECTOR);
|
|
188
|
+
if (!divs)
|
|
189
|
+
return;
|
|
190
|
+
for (var i = 0; i < divs.length; i += 1) {
|
|
191
|
+
var d = divs[i];
|
|
192
|
+
var vendor = getVendorForDiv(d, zNearMax, uuidGate, debug);
|
|
193
|
+
if (seen.indexOf(d) === -1 && vendor) {
|
|
194
|
+
seen.push(d);
|
|
195
|
+
handleMatch(d, vendor);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function startHoneyOverlayObserver(options) {
|
|
200
|
+
var _a, _b, _c, _d, _e;
|
|
201
|
+
if (options === void 0) {
|
|
202
|
+
options = {};
|
|
203
|
+
}
|
|
204
|
+
var seen = [];
|
|
205
|
+
var zNearMax = (_a = options.zNearMax) !== null && _a !== void 0 ? _a : DEFAULT_Z_NEAR_MAX;
|
|
206
|
+
var uuidGate = (_b = options.uuidGate) !== null && _b !== void 0 ? _b : true;
|
|
207
|
+
var debug = (_c = options.debug) !== null && _c !== void 0 ? _c : false;
|
|
208
|
+
var removeHoney = (_d = options.removeHoney) !== null && _d !== void 0 ? _d : true;
|
|
209
|
+
var unbindAfterSeconds = options.unbindAfterSeconds;
|
|
210
|
+
var warn = function(message) {
|
|
211
|
+
return showOverlay(message);
|
|
212
|
+
};
|
|
213
|
+
var onMatch = (_e = options.onMatch) !== null && _e !== void 0 ? _e : (function() {
|
|
214
|
+
});
|
|
215
|
+
var matched = false;
|
|
216
|
+
var unbindTimer;
|
|
217
|
+
var handleMatch = function(el, vendor) {
|
|
218
|
+
matched = true;
|
|
219
|
+
if (typeof unbindTimer === "number") {
|
|
220
|
+
clearTimeout(unbindTimer);
|
|
221
|
+
unbindTimer = void 0;
|
|
222
|
+
}
|
|
223
|
+
if (removeHoney && el.parentNode)
|
|
224
|
+
el.parentNode.removeChild(el);
|
|
225
|
+
if (removeHoney) {
|
|
226
|
+
onMatch(warn, void 0, vendor);
|
|
227
|
+
} else {
|
|
228
|
+
onMatch(warn, el, vendor);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
var mo = new MutationObserver(function(mutations) {
|
|
232
|
+
for (var _i = 0, mutations_1 = mutations; _i < mutations_1.length; _i++) {
|
|
233
|
+
var m = mutations_1[_i];
|
|
234
|
+
if (debug && document.body && (m.target === document.body || m.target instanceof Node && document.body.contains(m.target))) {
|
|
235
|
+
console.log("+++ body mutation", m.type, m.target);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
for (var _a2 = 0, mutations_2 = mutations; _a2 < mutations_2.length; _a2++) {
|
|
239
|
+
var m = mutations_2[_a2];
|
|
240
|
+
if (m.type === "childList") {
|
|
241
|
+
if (m.addedNodes.length) {
|
|
242
|
+
for (var i = 0; i < m.addedNodes.length; i += 1) {
|
|
243
|
+
var node = m.addedNodes[i];
|
|
244
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
245
|
+
scanElement(node, seen, zNearMax, uuidGate, debug, handleMatch);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (m.target instanceof Element) {
|
|
250
|
+
scanElement(m.target, seen, zNearMax, uuidGate, debug, handleMatch);
|
|
251
|
+
}
|
|
252
|
+
} else if (m.type === "attributes") {
|
|
253
|
+
if (m.target instanceof Element) {
|
|
254
|
+
scanElement(m.target, seen, zNearMax, uuidGate, debug, handleMatch);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
mo.observe(document.documentElement, {
|
|
260
|
+
subtree: true,
|
|
261
|
+
childList: true,
|
|
262
|
+
attributes: true,
|
|
263
|
+
attributeFilter: ["style", "class", "id"]
|
|
264
|
+
});
|
|
265
|
+
scanElement(document.documentElement, seen, zNearMax, uuidGate, debug, handleMatch);
|
|
266
|
+
if (typeof unbindAfterSeconds === "number" && unbindAfterSeconds > 0) {
|
|
267
|
+
unbindTimer = window.setTimeout(function() {
|
|
268
|
+
if (!matched) {
|
|
269
|
+
mo.disconnect();
|
|
270
|
+
}
|
|
271
|
+
}, unbindAfterSeconds * 1e3);
|
|
272
|
+
}
|
|
273
|
+
return {
|
|
274
|
+
stop: function() {
|
|
275
|
+
mo.disconnect();
|
|
276
|
+
if (typeof unbindTimer === "number") {
|
|
277
|
+
clearTimeout(unbindTimer);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function listen(onMatch, options) {
|
|
283
|
+
if (options === void 0) {
|
|
284
|
+
options = {};
|
|
285
|
+
}
|
|
286
|
+
return startHoneyOverlayObserver(__assign(__assign({}, options), { onMatch: onMatch }));
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// dist/bundle-tmp/global.js
|
|
290
|
+
if (typeof window !== "undefined") {
|
|
291
|
+
window.couponShield = window.couponShield || {};
|
|
292
|
+
window.couponShield.listen = listen;
|
|
293
|
+
window.couponShield.version = version;
|
|
294
|
+
}
|
|
295
|
+
})();
|