MicrosoftEdge / DevTools

Feedback and discussions about Microsoft Edge Developer Tools
MIT License
151 stars 49 forks source link

JSON Viewer - window.getSelection() not returning full text selection for browser extension #257

Open netbroom opened 1 month ago

netbroom commented 1 month ago

For the JSON viewer, window.getSelection() only returns what is in the user's viewport if a whole JSON document is selected. This is causing problems for our browser extension.

I understand that browser extensions do not have access to the page's JS code so even if window.getSelection() were to be overridden, extensions would not have access.

Copy + paste still works fine if performed by the user, so I'm assuming there is already some interception/override of selection APIs.

AB#51282586

captainbrosset commented 1 month ago

I think the reason for this is that the JSON viewer is using a web editor JS-based library to render the JSON content. This library optimizes for speed by only rendering to the DOM what can fit in the viewport. Copy/Paste probably works thanks to the library too. But I'm afraid getting the JSON by querying the DOM won't work, because the content is just not there entirely.

We have already received a request to expose the entire JSON data to the page context. So, for example, you could do window.jsonData and get the entire JSON object. I guess this would help you in your case.

Unfortunately, we've not yet prioritized working on this.