Filter out start of JSON responses
I sometimes use firefox to view data from APIs, however many private APIs include strings, usually `while(1);`, at the start of the JSON response for security reasons.
Is there a way to get firefox to filter out these strings, so it can parse the json?
Všetky odpovede (1)
You can possibly use a JavaScript bookmarklet to clean up the code if you have loaded the JSON response in a tab. Valid JSON usually starts with a '{' or a '[' and you can strip off leading characters. You may have to refine the code if it isn't working in special cases as I do not have examples to test it.
javascript:(function(){var t=document.querySelector('body>pre');t.textContent=t.textContent.replace(/^([^\[{])*(.*)/,'$2');})()