wineater-bot 1.8.1 → 1.8.2
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/dist/wineater-chatbot.mjs +670 -654
- package/dist/wineater-chatbot.umd.js +11 -11
- package/package.json +1 -1
- package/src/js/auto-open.js +24 -5
package/package.json
CHANGED
package/src/js/auto-open.js
CHANGED
|
@@ -3,6 +3,16 @@ const DEFAULT_URL_PATTERNS = {
|
|
|
3
3
|
// CART_PAGE: /carrito\/$/ // Matches the cart page like 'carrito/'
|
|
4
4
|
};
|
|
5
5
|
|
|
6
|
+
const DEFAULT_URL_ANTI_PATTERNS = {
|
|
7
|
+
FESTIVAL_PAGES: /festival/, // Matches any URL containing 'festival'
|
|
8
|
+
TASTING_PAGES: /tasting/ // Matches any URL containing 'tasting'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const urlAntiPatterns = {
|
|
12
|
+
FESTIVAL_PAGES: window.wineaterData?.FESTIVAL_PAGES || DEFAULT_URL_ANTI_PATTERNS.FESTIVAL_PAGES,
|
|
13
|
+
TASTING_PAGES: window.wineaterData?.TASTING_PAGES || DEFAULT_URL_ANTI_PATTERNS.TASTING_PAGES
|
|
14
|
+
};
|
|
15
|
+
|
|
6
16
|
// Retrieve custom or default URL patterns from wineaterData
|
|
7
17
|
const urlPatterns = {
|
|
8
18
|
PRODUCT_PAGES: window.wineaterData?.PRODUCT_PAGES || DEFAULT_URL_PATTERNS.PRODUCT_PAGES,
|
|
@@ -11,10 +21,19 @@ const urlPatterns = {
|
|
|
11
21
|
|
|
12
22
|
export function shouldOpenChatAutomatically() {
|
|
13
23
|
const currentURL = window.location.href;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
// Check if the current URL matches any of the anti-patterns
|
|
25
|
+
for (const [key, regex] of Object.entries(urlAntiPatterns)) {
|
|
26
|
+
if (regex.test(currentURL)) {
|
|
27
|
+
return false; // Do not open chat if URL matches an anti-pattern
|
|
28
|
+
}
|
|
18
29
|
}
|
|
19
|
-
|
|
30
|
+
|
|
31
|
+
// Check if the current URL matches any of the patterns
|
|
32
|
+
for (const [key, regex] of Object.entries(urlPatterns)) {
|
|
33
|
+
if (regex.test(currentURL)) {
|
|
34
|
+
return true; // Open chat if URL matches a pattern
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return false; // Default to not opening chat if no patterns match
|
|
20
39
|
}
|