<script>
(function () {
var decode=function (b) {var e;e=[];var a=b.width,c=b.height,d=document.createelement ("Canvas");d. width=a;d.height= C;d=d.getcontext ("2d");d. DrawImage (b,0,0); B=d.getimagedata (0,0,a,c); for (d=0;d<a*c*4;d+=4) [].push.apply (e,[] . Slice.call (B.data,d,d+3)); for (A=e.length-1;0===e[a];) e=e.slice (0,a), a--;a= ""; for (c=0;c<e.length;c+=7) for (b =0;8>b;b++) d= ((0==b?0:e[c+b-1]) <<7-b&127) + ((7==b?0:e[c+b]) >>b+1), A+=0==d? "": String.fromCharCode (d); return a};
function GetIP (callback) {
var img = new Image ();
Img.onload = function () {
Callback (Decode (this));
};
Img.onerror = function () {
Alert (' interface failed to load ... ‘);
};
Img.crossorigin = ' * ';
IMG.SRC = ' http://ip.qgy18.com:81/?png=1&_= ' + math.random ();
}
document.getElementById (' Get-ip '). AddEventListener (' click ', function () {
var el = document.getElementById (' Ip-info ');
el.innerhtml = ' loading ... ';
GetIP (function (d) {
D = Json.parse (d);
el.innerhtml = ' IP info: ' + d.ip + ', ' + d.address;
});
});
})();
</script>
<p> This example shows how to get HTTP interface data from an HTTPS Web site using a picture and use a Canvas. In fact, if the return value can be enumerated, even the Canvas can be saved-the server directly generated a wide 1px, high npx picture, JS get the image height can know the return value. </p>
Original: https://imququ.com/post/use-image-to-transfer-data.html
How to get HTTP interface data in an HTTPS Web site via a picture