Skip to content

Commit

Permalink
Better handling for getting patreon post data
Browse files Browse the repository at this point in the history
  • Loading branch information
sneat committed Jul 30, 2021
1 parent 4e0c9ae commit afcf4b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions contentScript.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit afcf4b3

Please sign in to comment.