Skip to content

Commit 103936f

Browse files
authored
Second request rollback (#31)
1 parent ddca3b6 commit 103936f

4 files changed

Lines changed: 13 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.5.4 (11-09-2019)
2+
3+
* Do not use second request, match JSON on markup instead
4+
15
## 1.5.3 (01-09-2019)
26

37
* Fixed false extension triggering on some sites

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsondiscovery",
3-
"version": "1.5.3",
3+
"version": "1.5.4",
44
"description": "DiscoveryJson",
55
"author": "exsdis@gmail.com",
66
"license": "MIT",

src/content/init.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,17 @@ export async function init(getSettings) {
1212
let json;
1313
let raw;
1414

15+
const { firstElementChild } = document.body;
1516
let { textContent } = document.body;
17+
1618
textContent = textContent.trim();
1719

18-
if (textContent.startsWith('{') || textContent.startsWith('[')) {
20+
if (
21+
(firstElementChild && firstElementChild.tagName === 'PRE') &&
22+
(textContent.startsWith('{') || textContent.startsWith('['))
23+
) {
1924
try {
20-
if (!window.location.protocol.startsWith('file')) {
21-
let fetchTest = await (await fetch(window.location.href)).text();
22-
fetchTest = fetchTest.trim();
23-
if (fetchTest.startsWith('{') || fetchTest.startsWith('[')) {
24-
json = JSON.parse(textContent);
25-
}
26-
} else {
27-
json = JSON.parse(textContent);
28-
}
25+
json = JSON.parse(textContent);
2926
} catch (_) {}
3027
}
3128

0 commit comments

Comments
 (0)