coupon-shield 0.3.11 → 0.3.12
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 +12 -13
- package/dist/auto.js +7 -7
- package/dist/bundle-tmp/auto.js +1 -1
- package/dist/bundle-tmp/core.js +5 -5
- package/dist/bundle-tmp/version.js +1 -1
- package/dist/couponshield.js +6 -6
- package/dist/esm/core.js +5 -5
- package/dist/esm/version.js +1 -1
- package/dist/types/core.d.ts +3 -3
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,9 +5,7 @@ Tool for eComm merchants to detect, warn and prevent a customer from shopping us
|
|
|
5
5
|
<img width="1307" height="561" alt="image" src="https://github.com/user-attachments/assets/33b2554b-fc90-4b4b-b917-4ed088664200" />
|
|
6
6
|
|
|
7
7
|
## Easy install (no-JS)
|
|
8
|
-
This will automatically
|
|
9
|
-
|
|
10
|
-
Install this at the very top of the `<head>` in your webpage to ensure it runs prior to Honey.
|
|
8
|
+
This will automatically detect a coupon extension and show a default warning to the user to disable the extension as shown above). Install this at the very top of the `<head>` in your webpage to ensure it runs prior to the extension.
|
|
11
9
|
[jsDelivr package page](https://www.jsdelivr.com/package/npm/coupon-shield).
|
|
12
10
|
```html
|
|
13
11
|
<script src="https://cdn.jsdelivr.net/npm/coupon-shield@latest/dist/auto.min.js"></script>
|
|
@@ -16,10 +14,10 @@ Install this at the very top of the `<head>` in your webpage to ensure it runs p
|
|
|
16
14
|
## Custom Usage (Browser Global)
|
|
17
15
|
|
|
18
16
|
```html
|
|
19
|
-
<script src="https://cdn.jsdelivr.net/npm/coupon-shield@latest/dist/couponshield.js"></script>
|
|
17
|
+
<script src="https://cdn.jsdelivr.net/npm/coupon-shield@latest/dist/couponshield.min.js"></script>
|
|
20
18
|
<script>
|
|
21
|
-
window.couponShield.listen((warn,
|
|
22
|
-
// Decide how you want to handle this. Native warn function allows you to tell the user to disable
|
|
19
|
+
window.couponShield.listen((warn, vendor) => {
|
|
20
|
+
// Decide how you want to handle this. Native warn function allows you to tell the user to disable the extension.
|
|
23
21
|
// vendor is "honey", "Capital One Shopping", or "Rakuten"
|
|
24
22
|
warn("You must disable the Honey extension to continue.");
|
|
25
23
|
});
|
|
@@ -35,8 +33,8 @@ npm install coupon-shield
|
|
|
35
33
|
```js
|
|
36
34
|
import { listen } from "coupon-shield";
|
|
37
35
|
|
|
38
|
-
listen((warn,
|
|
39
|
-
// Decide how you want to handle this. Native warn function allows you to tell the user to disable
|
|
36
|
+
listen((warn, vendor) => {
|
|
37
|
+
// Decide how you want to handle this. Native warn function allows you to tell the user to disable the extension.
|
|
40
38
|
// vendor is "honey", "Capital One Shopping", or "Rakuten"
|
|
41
39
|
warn("You must disable the Honey extension to continue.");
|
|
42
40
|
});
|
|
@@ -45,15 +43,16 @@ listen((warn, el, vendor) => {
|
|
|
45
43
|
## Advanced Options
|
|
46
44
|
|
|
47
45
|
```js
|
|
48
|
-
window.couponShield.listen((warn,
|
|
49
|
-
//
|
|
50
|
-
// Set
|
|
46
|
+
window.couponShield.listen((warn, vendor, el) => {
|
|
47
|
+
// removePageElement defaults to true (extension element loaded onto the page is auto-removed).
|
|
48
|
+
// Set removePageElement to false if you want to keep the extension element for some reason.
|
|
49
|
+
// el is only defined when removePageElement is false.
|
|
51
50
|
// vendor is "honey", "Capital One Shopping", or "Rakuten"
|
|
52
|
-
}, {
|
|
51
|
+
}, { removePageElement: false });
|
|
53
52
|
```
|
|
54
53
|
|
|
55
54
|
```js
|
|
56
|
-
window.couponShield.listen((warn) => {
|
|
55
|
+
window.couponShield.listen((warn, vendor) => {
|
|
57
56
|
// Stop observing if nothing is detected within 10 seconds.
|
|
58
57
|
}, { unbindAfterSeconds: 10 });
|
|
59
58
|
```
|
package/dist/auto.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function() {
|
|
2
2
|
// dist/bundle-tmp/version.js
|
|
3
|
-
var VERSION = "0.3.
|
|
3
|
+
var VERSION = "0.3.12";
|
|
4
4
|
|
|
5
5
|
// dist/bundle-tmp/core.js
|
|
6
6
|
var __assign = function() {
|
|
@@ -205,7 +205,7 @@
|
|
|
205
205
|
var zNearMax = (_a = options.zNearMax) !== null && _a !== void 0 ? _a : DEFAULT_Z_NEAR_MAX;
|
|
206
206
|
var uuidGate = (_b = options.uuidGate) !== null && _b !== void 0 ? _b : true;
|
|
207
207
|
var debug = (_c = options.debug) !== null && _c !== void 0 ? _c : false;
|
|
208
|
-
var
|
|
208
|
+
var removePageElement = (_d = options.removePageElement) !== null && _d !== void 0 ? _d : true;
|
|
209
209
|
var unbindAfterSeconds = options.unbindAfterSeconds;
|
|
210
210
|
var warn = function(message) {
|
|
211
211
|
return showOverlay(message);
|
|
@@ -220,12 +220,12 @@
|
|
|
220
220
|
clearTimeout(unbindTimer);
|
|
221
221
|
unbindTimer = void 0;
|
|
222
222
|
}
|
|
223
|
-
if (
|
|
223
|
+
if (removePageElement && el.parentNode)
|
|
224
224
|
el.parentNode.removeChild(el);
|
|
225
|
-
if (
|
|
226
|
-
onMatch(warn, void 0
|
|
225
|
+
if (removePageElement) {
|
|
226
|
+
onMatch(warn, vendor, void 0);
|
|
227
227
|
} else {
|
|
228
|
-
onMatch(warn,
|
|
228
|
+
onMatch(warn, vendor, el);
|
|
229
229
|
}
|
|
230
230
|
};
|
|
231
231
|
var mo = new MutationObserver(function(mutations) {
|
|
@@ -296,7 +296,7 @@
|
|
|
296
296
|
window.couponShield = window.couponShield || {};
|
|
297
297
|
window.couponShield.listen = listen;
|
|
298
298
|
window.couponShield.version = version;
|
|
299
|
-
window.couponShieldHandle = window.couponShield.listen(function(warn,
|
|
299
|
+
window.couponShieldHandle = window.couponShield.listen(function(warn, vendor) {
|
|
300
300
|
var vendorName = vendor || "honey";
|
|
301
301
|
var vendorLabel = vendorName.charAt(0).toUpperCase() + vendorName.slice(1);
|
|
302
302
|
warn(buildAutoModalHtml(vendorLabel));
|
package/dist/bundle-tmp/auto.js
CHANGED
|
@@ -20,7 +20,7 @@ if (typeof window !== "undefined") {
|
|
|
20
20
|
window.couponShield = window.couponShield || {};
|
|
21
21
|
window.couponShield.listen = listen;
|
|
22
22
|
window.couponShield.version = version;
|
|
23
|
-
window.couponShieldHandle = window.couponShield.listen(function (warn,
|
|
23
|
+
window.couponShieldHandle = window.couponShield.listen(function (warn, vendor) {
|
|
24
24
|
var vendorName = vendor || "honey";
|
|
25
25
|
var vendorLabel = vendorName.charAt(0).toUpperCase() + vendorName.slice(1);
|
|
26
26
|
warn(buildAutoModalHtml(vendorLabel));
|
package/dist/bundle-tmp/core.js
CHANGED
|
@@ -202,7 +202,7 @@ export function startHoneyOverlayObserver(options) {
|
|
|
202
202
|
var zNearMax = (_a = options.zNearMax) !== null && _a !== void 0 ? _a : DEFAULT_Z_NEAR_MAX;
|
|
203
203
|
var uuidGate = (_b = options.uuidGate) !== null && _b !== void 0 ? _b : true;
|
|
204
204
|
var debug = (_c = options.debug) !== null && _c !== void 0 ? _c : false;
|
|
205
|
-
var
|
|
205
|
+
var removePageElement = (_d = options.removePageElement) !== null && _d !== void 0 ? _d : true;
|
|
206
206
|
var unbindAfterSeconds = options.unbindAfterSeconds;
|
|
207
207
|
var warn = function (message) { return showOverlay(message); };
|
|
208
208
|
var onMatch = (_e = options.onMatch) !== null && _e !== void 0 ? _e : (function () { });
|
|
@@ -214,13 +214,13 @@ export function startHoneyOverlayObserver(options) {
|
|
|
214
214
|
clearTimeout(unbindTimer);
|
|
215
215
|
unbindTimer = undefined;
|
|
216
216
|
}
|
|
217
|
-
if (
|
|
217
|
+
if (removePageElement && el.parentNode)
|
|
218
218
|
el.parentNode.removeChild(el);
|
|
219
|
-
if (
|
|
220
|
-
onMatch(warn,
|
|
219
|
+
if (removePageElement) {
|
|
220
|
+
onMatch(warn, vendor, undefined);
|
|
221
221
|
}
|
|
222
222
|
else {
|
|
223
|
-
onMatch(warn,
|
|
223
|
+
onMatch(warn, vendor, el);
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
226
|
// Greedy, page-wide observer: Honey overlays can be inserted late, moved,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Auto-generated from package.json. Do not edit by hand.
|
|
2
|
-
export var VERSION = "0.3.
|
|
2
|
+
export var VERSION = "0.3.12";
|
package/dist/couponshield.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function() {
|
|
2
2
|
// dist/bundle-tmp/version.js
|
|
3
|
-
var VERSION = "0.3.
|
|
3
|
+
var VERSION = "0.3.12";
|
|
4
4
|
|
|
5
5
|
// dist/bundle-tmp/core.js
|
|
6
6
|
var __assign = function() {
|
|
@@ -205,7 +205,7 @@
|
|
|
205
205
|
var zNearMax = (_a = options.zNearMax) !== null && _a !== void 0 ? _a : DEFAULT_Z_NEAR_MAX;
|
|
206
206
|
var uuidGate = (_b = options.uuidGate) !== null && _b !== void 0 ? _b : true;
|
|
207
207
|
var debug = (_c = options.debug) !== null && _c !== void 0 ? _c : false;
|
|
208
|
-
var
|
|
208
|
+
var removePageElement = (_d = options.removePageElement) !== null && _d !== void 0 ? _d : true;
|
|
209
209
|
var unbindAfterSeconds = options.unbindAfterSeconds;
|
|
210
210
|
var warn = function(message) {
|
|
211
211
|
return showOverlay(message);
|
|
@@ -220,12 +220,12 @@
|
|
|
220
220
|
clearTimeout(unbindTimer);
|
|
221
221
|
unbindTimer = void 0;
|
|
222
222
|
}
|
|
223
|
-
if (
|
|
223
|
+
if (removePageElement && el.parentNode)
|
|
224
224
|
el.parentNode.removeChild(el);
|
|
225
|
-
if (
|
|
226
|
-
onMatch(warn, void 0
|
|
225
|
+
if (removePageElement) {
|
|
226
|
+
onMatch(warn, vendor, void 0);
|
|
227
227
|
} else {
|
|
228
|
-
onMatch(warn,
|
|
228
|
+
onMatch(warn, vendor, el);
|
|
229
229
|
}
|
|
230
230
|
};
|
|
231
231
|
var mo = new MutationObserver(function(mutations) {
|
package/dist/esm/core.js
CHANGED
|
@@ -202,7 +202,7 @@ export function startHoneyOverlayObserver(options) {
|
|
|
202
202
|
var zNearMax = (_a = options.zNearMax) !== null && _a !== void 0 ? _a : DEFAULT_Z_NEAR_MAX;
|
|
203
203
|
var uuidGate = (_b = options.uuidGate) !== null && _b !== void 0 ? _b : true;
|
|
204
204
|
var debug = (_c = options.debug) !== null && _c !== void 0 ? _c : false;
|
|
205
|
-
var
|
|
205
|
+
var removePageElement = (_d = options.removePageElement) !== null && _d !== void 0 ? _d : true;
|
|
206
206
|
var unbindAfterSeconds = options.unbindAfterSeconds;
|
|
207
207
|
var warn = function (message) { return showOverlay(message); };
|
|
208
208
|
var onMatch = (_e = options.onMatch) !== null && _e !== void 0 ? _e : (function () { });
|
|
@@ -214,13 +214,13 @@ export function startHoneyOverlayObserver(options) {
|
|
|
214
214
|
clearTimeout(unbindTimer);
|
|
215
215
|
unbindTimer = undefined;
|
|
216
216
|
}
|
|
217
|
-
if (
|
|
217
|
+
if (removePageElement && el.parentNode)
|
|
218
218
|
el.parentNode.removeChild(el);
|
|
219
|
-
if (
|
|
220
|
-
onMatch(warn,
|
|
219
|
+
if (removePageElement) {
|
|
220
|
+
onMatch(warn, vendor, undefined);
|
|
221
221
|
}
|
|
222
222
|
else {
|
|
223
|
-
onMatch(warn,
|
|
223
|
+
onMatch(warn, vendor, el);
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
226
|
// Greedy, page-wide observer: Honey overlays can be inserted late, moved,
|
package/dist/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Auto-generated from package.json. Do not edit by hand.
|
|
2
|
-
export var VERSION = "0.3.
|
|
2
|
+
export var VERSION = "0.3.12";
|
package/dist/types/core.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export declare const version = "0.3.
|
|
1
|
+
export declare const version = "0.3.12";
|
|
2
2
|
export type WarnCallback = (message: string) => () => void;
|
|
3
3
|
export type DetectedVendor = "honey" | "Capital One Shopping" | "Rakuten";
|
|
4
|
-
export type MatchCallback = (warn: WarnCallback,
|
|
4
|
+
export type MatchCallback = (warn: WarnCallback, vendor?: DetectedVendor, el?: HTMLDivElement) => void;
|
|
5
5
|
export interface ObserverOptions {
|
|
6
6
|
onMatch?: MatchCallback;
|
|
7
7
|
uuidGate?: boolean;
|
|
8
8
|
zNearMax?: number;
|
|
9
9
|
debug?: boolean;
|
|
10
|
-
|
|
10
|
+
removePageElement?: boolean;
|
|
11
11
|
unbindAfterSeconds?: number;
|
|
12
12
|
}
|
|
13
13
|
export interface ObserverHandle {
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.3.
|
|
1
|
+
export declare const VERSION = "0.3.12";
|