Advertisement
caffeinatedmike

Attempt #2 pa511cams

Oct 10th, 2018
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.67 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script>
  4. var myCamTimer, myCamTimeout, dial1;
  5. function refreshCamera() {
  6.     var b = new Date;
  7.     var addr = "https://pa511cams.ilchost.com/cameras/d6/CAM-06-470.jpg?nocache="
  8.     a = document.getElementById("myCam");
  9.    
  10.     var xhr = new XMLHttpRequest();
  11.     xhr.responseType = 'blob'; //so you can access the response like a normal URL
  12.     xhr.onreadystatechange = function () {
  13.         if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
  14.             a.src = URL.createObjectURL(xhr.response); //create <img> with src set to the blob
  15.         }
  16.     };
  17.     xhr.open('GET', addr + b.getTime(), true);
  18.     xhr.setRequestHeader('Referer', 'https://www.511pa.com/CameraListing.aspx');
  19.     xhr.send();
  20.     //a.src = a.src.substring(0, a.src.indexOf("nocache=")) + "nocache=" + b.getTime()
  21. }
  22. function startCamRefresh() {
  23.     clearInterval(myCamTimer);
  24.     clearTimeout(myCamTimeout);
  25.     myCamTimer = setInterval(function() {
  26.         refreshCamera()
  27.     }, 5e3);
  28.     myCamTimeout = setTimeout(function() {
  29.         stopCamRefresh()
  30.     }, 65e3);
  31.     try {
  32.         document.getElementById("camRefLink").style.visibility = "hidden";
  33.     } catch (a) {}
  34. }
  35. function stopCamRefresh() {
  36.     clearInterval(myCamTimer);
  37.     clearTimeout(myCamTimeout);
  38.     try {
  39.         document.getElementById("camRefLink").style.visibility = "visible";
  40.     } catch (a) {}
  41. }
  42. </script>
  43. </head>
  44. <body onload=startCamRefresh()>
  45.  
  46. <img id="myCam" style="height:240px;width:352px;"
  47.      title="cam image - US 1 NB at Old Lincoln Highway"
  48.     src="https://pa511cams.ilchost.com/cameras/d6/CAM-06-470.jpg?nocache=1539188740869">
  49. <div id="camRefLink" style="visibility:hidden">Stream Timed Out</div>
  50. </body>
  51. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement