var visipisi = {
mozilla: function(url, cb) {
var tries = 1;
var start, intervaller;
var runtest = function () {
var count = 0;
var img = new Image();
img.onload = function () {
if (++count == 1)
cbWrap(true);
};
start = new Date().getTime();
img.src = url;
var timeoutCB = function () {
var now = new Date().getTime();
if (now - start > 10) {
window.stop();
window.stop();
window.clearInterval(intervaller);
if (++count == 1) {
cbWrap(false);
}
}
};
intervaller = window.setInterval(timeoutCB, 2);
};
cbWrap = function (value) {
if (--tries == 0)
cb(value);
else
window.setTimeout(runtest, 10);
};
runtest();
}
};
This page will tell you what websites you have recently visited! In other words, it will partially access your browser's history without your permission. This implies that any website on the Internet can do this. I got the inspiration from Michal's code after reading about it on HN.
The javascript code on this page attempts to guess if you have recently visited a website by loading an image from the target website. If the loading completes fast (less than 10ms), it is highly likely that it was loaded from browser's local cache as the network latency and speed of most Internet connections cannot deliver sub 10ms speed. If it takes longer, it's not in the cache. To avoid polluting the cache, the loading is interrupted at the 10ms mark. This is important because any subsequent tests will yield the same results.
Although the idea is simple, two factors affect the speed and accuracy of the test: the speed at which the browser loads content from its cache, and the realtimeness of the OS and the browser event system to allow interrupting the request at a precise time. Both of these factors further depend on the type of the browser, the OS and the CPU and IO load of the machine running the test. The ideal conditions are fast machine running real time OS with no CPU or IO load with a browser using a fast javascript implementation. Because of these factors, the accuracy of the test partially depends on your running environment. The goal is to make the test as independent of these factors as possible.
The other issue that I am yet to resolve is Firefox's lack of cooperation in loading stuff from cache. So for now, this is probably of no use on Firefox. It should however work reliable on webkit based browsers such as Chrome and Safari.
The entire code of this page (other than those external scripts linked to from this page) is licenced under GPL 3. If you have questions, suggestions or any kind of feedback, please email me at mansour [at] oxplot [dot] com
| facebook: | slashdot: | cnn: | abebooks: | ||||
|---|---|---|---|---|---|---|---|
| twitter: | myspace: | bbc: | msy: | ||||
| digg: | engadget: | reuters: | techbuy: | ||||
| reddit: | last.fm: | wikipedia: | borders (au): | ||||
| HN: | pandora: | amazon: | mozilla: | ||||
| stumbleupon: | youtube: | ebay (au): | anandtech: | ||||
| wired: | yahoo: | newegg: | tomshardware: | ||||
| xkcd: | google: | bestbuy: | shopbot (au): | ||||
| linkedin: | hotmail: | walmart: | staticice: | ||||
| pornhub: | redtube: | perfectgirls: | youporn: |