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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wineater-bot",
3
- "version": "1.8.1",
3
+ "version": "1.8.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",
@@ -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
- console.log(urlPatterns);
15
-
16
- if (urlPatterns.PRODUCT_PAGES.test(currentURL) || urlPatterns.CART_PAGE.test(currentURL)) {
17
- return true;
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
- return false;
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
  }