2017-11-07 19:51:49 +01:00
|
|
|
/* eslint no-console: off */
|
2017-08-13 23:44:31 +02:00
|
|
|
(function(){
|
2017-10-03 15:35:31 +02:00
|
|
|
"use strict";
|
|
|
|
|
2017-08-13 23:44:31 +02:00
|
|
|
function show(container, url){
|
2017-11-24 17:06:43 +01:00
|
|
|
var display = container.querySelector(".display");
|
|
|
|
display.src = url;
|
|
|
|
display.title = url;
|
2017-08-13 23:44:31 +02:00
|
|
|
var buffer = new TextEncoder("utf-8").encode(url);
|
|
|
|
crypto.subtle.digest("SHA-256", buffer).then(function(hash){
|
|
|
|
var chunks = [];
|
|
|
|
(new Uint32Array(hash)).forEach(function(num){
|
|
|
|
chunks.push(num.toString(16));
|
|
|
|
});
|
|
|
|
container.querySelector(".hash").textContent = chunks.map(function(chunk){
|
|
|
|
return "0".repeat(8 - chunk.length) + chunk;
|
|
|
|
}).join("");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (location.search !== "?notInitial"){
|
2017-10-10 20:33:42 +02:00
|
|
|
try {show(document.getElementById("top"), topTest());}
|
|
|
|
catch (e){console.error(e);}
|
|
|
|
try {show(document.getElementById("iframe"), iframeTest(document.querySelector("#iframe iframe")));}
|
|
|
|
catch (e){console.error(e);}
|
|
|
|
try {show(document.getElementById("iframe2"), iframeTest(document.querySelector("#iframe2 iframe")));}
|
|
|
|
catch (e){console.error(e);}
|
|
|
|
try {show(document.getElementById("iframe3"), iframeTest(document.querySelector("#iframe3 iframe")));}
|
|
|
|
catch (e){console.error(e);}
|
2017-08-13 23:44:31 +02:00
|
|
|
}
|
2017-10-06 16:06:31 +02:00
|
|
|
document.querySelector("#top button").addEventListener("click", function(){
|
|
|
|
show(document.getElementById("top"), topTest());
|
|
|
|
});
|
|
|
|
document.querySelector("#iframe button").addEventListener("click", function(){
|
2017-10-10 20:33:42 +02:00
|
|
|
show(document.getElementById("iframe"), iframeTest(document.querySelector("#iframe iframe")));
|
|
|
|
});
|
|
|
|
document.querySelector("#iframe2 button").addEventListener("click", function(){
|
|
|
|
show(document.getElementById("iframe2"), iframeTest(document.querySelector("#iframe2 iframe")));
|
|
|
|
});
|
|
|
|
document.querySelector("#iframe3 button").addEventListener("click", function(){
|
|
|
|
show(document.getElementById("iframe3"), iframeTest(document.querySelector("#iframe3 iframe")));
|
2017-10-06 16:06:31 +02:00
|
|
|
});
|
2017-08-13 23:44:31 +02:00
|
|
|
}());
|
|
|
|
|
|
|
|
function draw(canvas){
|
2017-10-03 15:35:31 +02:00
|
|
|
"use strict";
|
|
|
|
|
2017-08-13 23:44:31 +02:00
|
|
|
canvas.setAttribute("width", 220);
|
|
|
|
canvas.setAttribute("height", 30);
|
|
|
|
|
|
|
|
var fp_text = "BrowserLeaks,com <canvas> 10";
|
|
|
|
|
2017-10-03 15:35:31 +02:00
|
|
|
var ctx = canvas.getContext("2d");
|
2017-08-13 23:44:31 +02:00
|
|
|
ctx.textBaseline = "top";
|
|
|
|
ctx.font = "14px 'Arial'";
|
|
|
|
ctx.textBaseline = "alphabetic";
|
|
|
|
ctx.fillStyle = "#f60";
|
|
|
|
ctx.fillRect(125, 1, 62, 20);
|
|
|
|
ctx.fillStyle = "#069";
|
|
|
|
ctx.fillText(fp_text, 2, 15);
|
|
|
|
ctx.fillStyle = "rgba(102, 204, 0, 07)";
|
|
|
|
ctx.fillText(fp_text, 4, 17);
|
|
|
|
|
|
|
|
return ctx;
|
|
|
|
}
|
|
|
|
|
|
|
|
function topTest(){
|
2017-10-03 15:35:31 +02:00
|
|
|
"use strict";
|
|
|
|
|
2017-08-13 23:44:31 +02:00
|
|
|
// create window canvas
|
2017-10-03 15:35:31 +02:00
|
|
|
var canvas = document.createElement("canvas");
|
2017-08-13 23:44:31 +02:00
|
|
|
// draw image in window canvas
|
|
|
|
draw(canvas);
|
|
|
|
return canvas.toDataURL();
|
|
|
|
}
|
|
|
|
|
2017-10-10 20:33:42 +02:00
|
|
|
function iframeTest(iframe){
|
2017-10-03 15:35:31 +02:00
|
|
|
"use strict";
|
2017-08-13 23:44:31 +02:00
|
|
|
|
|
|
|
// create window canvas
|
2017-10-03 15:35:31 +02:00
|
|
|
var canvas = document.createElement("canvas");
|
2017-08-13 23:44:31 +02:00
|
|
|
|
|
|
|
// draw image in window canvas
|
|
|
|
draw(canvas);
|
|
|
|
|
|
|
|
// create iframe canvas and ctx
|
2017-10-10 20:33:42 +02:00
|
|
|
var iframe_canvas = iframe.contentDocument.createElement("canvas");
|
2017-08-13 23:44:31 +02:00
|
|
|
iframe_canvas.setAttribute("width", 220);
|
|
|
|
iframe_canvas.setAttribute("height", 30);
|
2017-10-03 15:35:31 +02:00
|
|
|
var iframe_ctx = iframe_canvas.getContext("2d");
|
2017-08-13 23:44:31 +02:00
|
|
|
|
|
|
|
// copy image from window canvas to iframe ctx
|
|
|
|
iframe_ctx.drawImage(canvas, 0, 0);
|
|
|
|
|
|
|
|
return iframe_canvas.toDataURL();
|
|
|
|
}
|