Skip to content

Commit 51ede64

Browse files
committed
Ignore pages that are not main_frame loads
g
1 parent 3ad3acc commit 51ede64

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## JSONView 3.1.0
2+
3+
- Restricted JSONView to only act on main frame loads - this should prevent it from doing weird things to pages loaded in frames or via fetch/XHR. This should fix reported issues of JSONView causing trouble on Sharepoint sites.
4+
15
## JSONView 3.0.2
26

37
- Fixed a regression in Firefox where JSON not served as UTF-8 (which is technically invalid) caused ugly characters to display in the formatted JSON.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ There are no hard and fast rules for what I will and will not accept - please ju
66

77
- Adding new MIME types to the set supported by JSONView. I have [an open issue](https://github.com/bhollis/jsonview/issues/7) for how I'd like to see additional MIME types handled, and will not accept patches that add arbitrary new MIME types.
88
- Adding new options. While I'm not opposed to adding an option if it really makes sense, the bar is very high for adding anything configurable to the add-on.
9-
- Interpreting JSON in any application-specific way. While in the past I've allowed a few feature additions that attempt to interpret JSON (such as recognizing and linkifying URLs), I want JSONView to be a general JSON viewer, and as such will reject any patch that seeks to priviledge specific interpretations of JSON structure.
9+
- Interpreting JSON in any application-specific way. While in the past I've allowed a few feature additions that attempt to interpret JSON (such as recognizing and linkifying URLs), I want JSONView to be a general JSON viewer, and as such will reject any patch that seeks to privilege specific interpretations of JSON structure.
1010
- Adding switches or options to the screen that shows JSON. I don't want to clutter up the JSON view itself with control panels and options, so anything that relies on adding such a thing is likely to be rejected.
1111

1212
Please, don't let this discourage you! Just file an issue first so we can discuss the change you plan to make.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Before contributing to JSONView, make sure to read the [Contributing Guidelines]
3232
- Run `pnpm start` to build the extension.
3333
- In Firefox, go to `about:debugging#addons` in the address bar, check "Enable add-on debugging", select "Load Temporary Add-on", and choose the `jsonview/build-firefox/manifest.json` file.
3434
- In Chrome, Edge, etc., go to `edge://extensions/`, in the address bar, enable "Developer mode", select "Load Unpacked", and choose the `jsonview/build-chrome` folder.
35+
- Run `pnpm tests` to start a little webserver that serves all the JSON files in `./tests`.
3536

3637
JSONView makes use of [TypeScript](https://www.typescriptlang.org/). I recommend [VSCode](https://code.visualstudio.com/) for editing the code - it will automatically prompt to install the correct extensions, and will highlight errors. All of the code that makes up the extension itself are in `src/`.
3738

src/background-chrome.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function isRedirect(status: number) {
1313
}
1414

1515
function detectJSON(event: chrome.webRequest.WebResponseHeadersDetails) {
16-
if (!event.responseHeaders || isRedirect(event.statusCode)) {
16+
if (!event.responseHeaders || event.type !== "main_frame" || isRedirect(event.statusCode)) {
1717
return;
1818
}
1919
for (const header of event.responseHeaders) {
@@ -34,7 +34,7 @@ function detectJSON(event: chrome.webRequest.WebResponseHeadersDetails) {
3434
chrome.webRequest.onHeadersReceived.addListener(
3535
detectJSON,
3636
{ urls: ["<all_urls>"], types: ["main_frame"] },
37-
["responseHeaders"]
37+
["responseHeaders"],
3838
);
3939

4040
// Listen for a message from the content script to decide whether to operate on

src/background-firefox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function isRedirect(status: number) {
1313
}
1414

1515
function detectJSON(event: chrome.webRequest.WebResponseHeadersDetails) {
16-
if (!event.responseHeaders || isRedirect(event.statusCode)) {
16+
if (!event.responseHeaders || event.type !== "main_frame" || isRedirect(event.statusCode)) {
1717
return;
1818
}
1919
for (const header of event.responseHeaders) {

0 commit comments

Comments
 (0)