There is some javascript that is connecting to around 40 different websites. If you are logged into any of these sites already then they don't return a login prompt so the site knows that you are logged in.
Javascript in one site can't just access another website's content. That's the Same Origin Policy. But what you can do is dynamically link to an image on another website. You can't access its content, but you can know if it loaded correctly. So if you find some image that is only accessible to a logged-in user (non logged-in gets a redirect for example) you can determine logged in status.
Another technique uses time measurements and non-image resources. Loading them as an image will fail anyway, but if there is a substantial time difference in the error response for logged-in vs not, it can be done that way too.