0

I need a way to compare all the object information that is available in javascript. I tried copying window.navigator or just window with copy(window); in the chrome console. But for some reason when I want to copy the object or convert it to json I always get an error. I've been looking it up but I couldn't really find a way. What I need is a function that can give me a list of all javascript variables that are globally available just like this site doesbrowserspy.dk/showprop.php. This site lists all global variables and functions, I want the same but preferably in a JSON format or any other raw text format that allows me to easily compare it and find the differences. I want to find out more information about how a browser could be tracked ect. I know about canvas fingerprinting and about those javascript variables.

What I hava already tried is JSON.stringify(window); but this gives me an

Uncaught TypeError: Converting circular structure to JSON
    at JSON.stringify (<anonymous>)
    at <anonymous>:1:6

I have tried looking this error up and came across Chrome sendrequest error: TypeError: Converting circular structure to JSON but I still got other errors when I tried the solutions. I don't mind if the object misses some data as long as I am able to compare all the variables that are different. I have tried many ways I found online already and the problems I keep getting are: It throws an error, or all the objects in the object are ignored. I also need all the info of for example window.navigator or window.navigator.webkitGetUserMedia and its sub-values like window.navigator.webkitGetUserMedia.length . How can this be accomplished?

2 Answers2

0

See this answer, worked for me: JSON.stringify, avoid TypeError: Converting circular structure to JSON.

Paste the function from that answer in your browser, then do JSON.stringifyOnce(window)

Kurt Furbush
  • 23
  • 1
  • 4
  • I hava already tried this and it works, sorth of. Try it yourself on the window object and then copy the result and search for navigator. now look in window.navigator trough the console. you can see that in the result of json.stringifyOnce there is only the code ,"navigator":{}, and the object navigator within the object window and all its variables are not in there. I need a deep clone and not a shallow one – Adrian Belmans Jun 13 '18 at 13:15
0

The problem, you face, is the windows object contains a property window, which is a circular reference to the window object.

For getting all keys, you could use Object.keys or Object.entries and filter the windows key.

console.log('window' in window);
console.log(Object.keys(window));
Nina Scholz
  • 376,160
  • 25
  • 347
  • 392
  • this does seem like a way to go, but how would I go on and put this some code that loops trough every object so that I can make a deep clone of window and all its other objects? I'm pretty noob at javascript I usually code in C#. the object.entries looks pretty interesting but the problem is that this is only works shallow – Adrian Belmans Jun 13 '18 at 13:26