Skip to content

Commit

Permalink
Second request rollback (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
exdis authored Sep 12, 2019
1 parent ddca3b6 commit 103936f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.5.4 (11-09-2019)

* Do not use second request, match JSON on markup instead

## 1.5.3 (01-09-2019)

* Fixed false extension triggering on some sites
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsondiscovery",
"version": "1.5.3",
"version": "1.5.4",
"description": "DiscoveryJson",
"author": "[email protected]",
"license": "MIT",
Expand Down
17 changes: 7 additions & 10 deletions src/content/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ export async function init(getSettings) {
let json;
let raw;

const { firstElementChild } = document.body;
let { textContent } = document.body;

textContent = textContent.trim();

if (textContent.startsWith('{') || textContent.startsWith('[')) {
if (
(firstElementChild && firstElementChild.tagName === 'PRE') &&
(textContent.startsWith('{') || textContent.startsWith('['))
) {
try {
if (!window.location.protocol.startsWith('file')) {
let fetchTest = await (await fetch(window.location.href)).text();
fetchTest = fetchTest.trim();
if (fetchTest.startsWith('{') || fetchTest.startsWith('[')) {
json = JSON.parse(textContent);
}
} else {
json = JSON.parse(textContent);
}
json = JSON.parse(textContent);
} catch (_) {}
}

Expand Down

0 comments on commit 103936f

Please sign in to comment.