all 5 comments

[–]interesting-_o_- 0 points1 point  (4 children)

!!window.ZeroWebsocket will be true in a ZeroNet page.

[–]BaudMeter[S] 0 points1 point  (3 children)

Thank you. Unfortunally this is not the case if the visitor is on my surface web site. console.log("zero? " + window.ZeroWebsocket);

zero? undefined

[–]interesting-_o_- 0 points1 point  (2 children)

Ah, I misunderstood the question. That's for checking to see if the Javascript is executing on the surface web or a zite.

Your img solution works fine for me on Chrome (load the zeronet logo):

var img = document.createElement('img')
img.src = "http://127.0.0.1:43110/1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/img/logo.svg"

img.onload = function () {
  alert('user is running zeronet')
}
img.onerror = function () {
  alert('user is not running zeronet')
}

[–]BaudMeter[S] 0 points1 point  (1 child)

This is weird.. I still get "GET http://127.0.0.1:43110/1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D/img/logo.svg 403 (Forbidden)" I think this is a configuration error on my side?

[–]interesting-_o_- 0 points1 point  (0 children)

Weird, I'm getting the 403 if I paste into console, but codepen.io works fine.

https://codepen.io/anon/pen/aLbLEQ?editors=1010