From afcf4b37882c98e61120f25de804e2b7a0c6a20b Mon Sep 17 00:00:00 2001 From: Blair McMillan Date: Fri, 30 Jul 2021 10:54:05 +1000 Subject: [PATCH] Better handling for getting patreon post data --- contentScript.js | 24 ++++++++++++++---------- manifest.json | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/contentScript.js b/contentScript.js index 1782243..71c59c1 100644 --- a/contentScript.js +++ b/contentScript.js @@ -1,15 +1,19 @@ try { chrome.runtime.sendMessage({type: 'whoAmI'}, tabId => { - const payload = '{'.concat(document.documentElement.innerHTML.split('Object.assign(window.patreon.bootstrap, {')[1].split(');')[0]); - const data = {}; - data[tabId.tab.toString()] = JSON.parse(payload); - chrome.storage.local.set(data, function () { - if (chrome.runtime.lastError) { - console.error('Patreon Downloader | Failed to set data for tab.', tabId.tab, data, chrome.runtime.lastError.message); - } else { - console.debug('Patreon Downloader | Set page data.', tabId.tab, data); - } - }); + try { + const payload = '{'.concat(document.documentElement.innerHTML.split('Object.assign(window.patreon.bootstrap, {')[1].split('\n});\n Object.assign(window.patreon')[0], '}'); + const data = {}; + data[tabId.tab.toString()] = JSON.parse(payload); + chrome.storage.local.set(data, function () { + if (chrome.runtime.lastError) { + console.error('Patreon Downloader | Failed to set data for tab.', tabId.tab, data, chrome.runtime.lastError.message); + } else { + console.debug('Patreon Downloader | Set page data.', tabId.tab, data); + } + }); + } catch (e) { + console.error('Patreon Downloader |', e); + } }); } catch (e) { console.error('Patreon Downloader |', e); diff --git a/manifest.json b/manifest.json index d88bb1d..381f9a8 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Patreon Downloader", - "version": "1.0.4", + "version": "1.0.5", "description": "Download media and attachments from Patreon pages.", "page_action": { "default_title": "Patreon Downloader",