Extension breaks when used with Lastpass Chrome Extension
dr3 opened this issue ยท 8 comments
When using the Lastpass Chrome Extension and loading a page with content-type: application/json; charset=utf-8
the extension doesn't load.
There are no console errors
This may be the cause of recent reviews https://chrome.google.com/webstore/detail/json-formatter/bcjindcccaagfpapjjmafapmmgkkhgoa/related?hl=en
Chrome: Version 104.0.5112.79
I have tried uninstalling/reinstalling to no success
I love this little extension and haven't found an equivalent or better option for Chrome, so I did a little debugging.
The problem comes from the assumption on this line:
bodyChildren.length !== 1
where the extension is assuming a JSON file loaded by Chrome will have a single PRE
element as a child element of the document's body. But if you open the dev tools and inspect the document's body, you see something like this:
Presumably, this little extra div
element:
<div style="position: static !important;"></div>
must be a "new feature" that came with the recent Chrome update.
I create a pull request with a fix. If the change is accepted, the extension should work again.
In the meantime, if you are able to use git to download a local copy of this repository, you can try this:
- In a terminal window in a folder where you can keep a local copy of the repository, create a local copy with
git clone https://github.com/callumlocke/json-formatter
- Make the one-line change in content.js (replacing
!== 1
with> 2
on line 236 of theextension/js/content.js
file. - View your extensions in Chrome, make sure developer mode is enabled, click the "Load unpacked" button, and select then
extension
folder within your local copy to load the patched extension.
Awesome stuff @bmamlin, hopefully @callumlocke has time to review & release soon ๐
I came here for the same issue. What's odd is that it works on the same webpage via Chrome Incognito if you enable the extension for Incognito browsing.
What's odd is that it works on the same webpage via Chrome Incognito if you enable the extension for Incognito browsing.
Interesting. If I open a JSON webpage in incognito with the extension disabled and inspect the page content, I see Chrome adding the extra div
element there too; however, you're right that the extension works. How could that be? When I introduce some logging statement, it looks like โ for whatever reason โ the extra div
is not present when JSON Formatter gets the page contents in incognito mode. All I can figure is the extra div
is being added after the page is loaded and somehow in incognito mode JSON Formatter manages to get invoked before the div
is added (so it isn't there to trip up JSON Formatter).
But that led me to think, maybe it's not Chrome after all... if it's a timing issue during page load, maybe the problem is being caused by another extension.
So, I disabled all my other extensions and discovered that JSON Formatter works if I disable the LastPass extension. Given other folks have mentioned that turning off their ad blocker helped in other cases, this may related.
Since I depend on LastPass, I'll be using the modified version of JSON Formatter for now... but it looks like this should be reclassified as an extension conflict rather than a Chrome bug.
What's odd is that it works on the same webpage via Chrome Incognito if you enable the extension for Incognito browsing.
Interesting. If I open a JSON webpage in incognito with the extension disabled and inspect the page content, I see Chrome adding the extra
div
element there too; however, you're right that the extension works. How could that be? When I introduce some logging statement, it looks like โ for whatever reason โ the extradiv
is not present when JSON Formatter gets the page contents in incognito mode. All I can figure is the extradiv
is being added after the page is loaded and somehow in incognito mode JSON Formatter manages to get invoked before thediv
is added (so it isn't there to trip up JSON Formatter).But that led me to think, maybe it's not Chrome after all... if it's a timing issue during page load, maybe the problem is being caused by another extension.
So, I disabled all my other extensions and discovered that JSON Formatter works if I disable the LastPass extension. Given other folks have mentioned that turning off their ad blocker helped in other cases, this may related.
Since I depend on LastPass, I'll be using the modified version of JSON Formatter for now... but it looks like this should be reclassified as an extension conflict rather than a Chrome bug.
Interesting finding! I can confirm disabling LastPass made the formatter work again.
Agree - removing the LastPass extension makes JSON Formatter work again.
Bye bye Lastpass - we have to make choices.
Should be fixed by #212, now released as v0.6.3.