hh-shipments 0.3.19 → 0.3.20

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
@@ -18,7 +18,7 @@
18
18
  "test": "node test/run-tests.js && node test/run-carriers-tests.js"
19
19
  },
20
20
  "type": "commonjs",
21
- "version": "0.3.19",
21
+ "version": "0.3.20",
22
22
  "bin": {
23
23
  "hh-shipments": "server.js"
24
24
  },
package/public/index.html CHANGED
@@ -4,7 +4,7 @@
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
6
6
  <meta name="theme-color" content="#0a84ff">
7
- <meta name="app-version" content="0.3.19">
7
+ <meta name="app-version" content="0.3.20">
8
8
  <title>HH Shipments</title>
9
9
  <link rel="manifest" href="/manifest.webmanifest">
10
10
  <link rel="apple-touch-icon" href="/icon-192.png">
package/src/extract.js CHANGED
@@ -90,25 +90,23 @@
90
90
  }
91
91
  }
92
92
  // Chat screenshots (Messenger): the other person's name is the header at
93
- // the very top ("Abdullah Sohail"), above the message bubbles. Take the
94
- // first title-case name in the top lines — never Hunter's own name /
95
- // address bubble, never app or chat UI words.
93
+ // the very top ("Abdullah Sohail"), above the message bubbles. OCR wraps
94
+ // it in garbage ("{® Abdullah Sohail LC Be"), so find the name *within*
95
+ // the top lines instead of requiring a clean line. Never Hunter's own
96
+ // name/address bubble, never app or chat UI words.
96
97
  if (!out.seller_name) {
97
98
  var cheadBlock = /\b(UPS|FEDEX|USPS|DHL|GROUND|EXPRESS|PRIORITY|BILLING|TRACKING|POSTAGE|LABEL|SHIPMENT|SHIP\b|SCREENSHOT|READING|FINDING|UPLOADING|EXTRACT|PASTE|DETAILS|SAVE|TAP|CLIPBOARD|NUMBER|BACK|HOME|ARCHIVE|SETTINGS|HUNTER|HILLS|THANK|THANKS|YOU|DELIVERED|SEEN|TYPING|AFTERMARKET|DISPLAY)\b/i;
98
99
  var clines = String(text).split(/\r?\n/);
99
100
  var checked = 0;
100
- for (var ci = 0; ci < clines.length && checked < 6; ci++) {
101
- var ch = clines[ci].trim();
102
- if (!ch || ch.length > 40) continue;
101
+ for (var ci = 0; ci < clines.length && checked < 8; ci++) {
102
+ var ch = clines[ci];
103
+ if (!ch || !ch.trim() || ch.length > 80) continue;
103
104
  checked++;
104
105
  if (/\d/.test(ch)) continue;
105
- var cw = ch.split(/\s+/);
106
- if (cw.length < 2 || cw.length > 3) continue;
107
- var cok = true;
108
- for (var cj = 0; cj < cw.length; cj++) if (!/^[A-Z][a-z]{2,}$/.test(cw[cj])) { cok = false; break; }
109
- if (!cok) continue;
110
- if (cheadBlock.test(ch)) continue;
111
- out.seller_name = ch;
106
+ var nm = ch.match(/\b([A-Z][a-z]{2,}(?:\s+[A-Z][a-z]{2,}){1,2})\b/);
107
+ if (!nm) continue;
108
+ if (cheadBlock.test(nm[1])) continue;
109
+ out.seller_name = nm[1];
112
110
  break;
113
111
  }
114
112
  }