eljeffeg / SmartCopy

Chrome extension for copying genealogical data into Geni.com.
15 stars 14 forks source link

AncestryFree - on long window.__PRELOADED_STATE JSON, regex matching fails #104

Closed GuyKh closed 9 months ago

GuyKh commented 2 years ago

I have issues with a profile (this):

When openning debugging tools in chrome - I see that the following:

Error handling response: SyntaxError: Unterminated string in JSON at position 4384
    at JSON.parse (<anonymous>)
    at Object.loadPage (chrome-extension://ofikakkdpjlipbnhbfloclbkcabdhjah/collections/ancestryfree.js:31:32)
    at loadPage (chrome-extension://ofikakkdpjlipbnhbfloclbkcabdhjah/popup.js:389:32)
    at chrome-extension://ofikakkdpjlipbnhbfloclbkcabdhjah/popup.js:790:17

and indeed - this text is 4384 chars long and is a faulty json. image

But when manually trying to fetch the window.__PRELOADED_STATE - it contains a JSON object in as long as 10792 chars long (which is valid).

Perhaps regex usage is not the way to work here.

GuyKh commented 2 years ago

Further investigation leads me to understand that the issue is with matching ; symbol -- as the text in the JSON is:

... Bhreitheamhnaigh</strong>; see <a href=\\"/name-origin?surname=breheny\\">Breheny</a>. Americanized form (translation into English....