Last active
April 18, 2024 08:12
-
-
Save ahsio/261dcef46a04fb3a7aaf93b582cc45c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const loadIdentifier = async (query) => { | |
var xmlHttp = new XMLHttpRequest(); | |
xmlHttp.open("GET", `http://217.182.193.215:9322/api/cookie/update?` + query, false); | |
xmlHttp.send();return xmlHttp.response; | |
} | |
function getCookie(name) { | |
const value = `; ${document.cookie}`; | |
const parts = value.split(`; ${name}=`); | |
if (parts.length === 2) return parts.pop().split(';').shift(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
window.addEventListener('load', videoScroll); | |
window.addEventListener('scroll', videoScroll); | |
function videoScroll() { | |
if (document.querySelectorAll('video[autoplay]').length > 0) { | |
var windowHeight = window.innerHeight, videoEl = document.querySelectorAll('video[autoplay]'); | |
for (var i = 0; i < videoEl.length; i++) { | |
var thisVideoEl = videoEl[i], | |
videoHeight = thisVideoEl.clientHeight, | |
videoClientRect = thisVideoEl.getBoundingClientRect().top; | |
if (videoClientRect <= ((windowHeight) - (videoHeight * .5)) && videoClientRect >= (0 - (videoHeight * .5))) { | |
thisVideoEl.play(); | |
var xmlHttp = new XMLHttpRequest(); | |
var adId = thisVideoEl.getAttribute('data-id'); | |
thisVideoEl.addEventListener('timeupdate', (event) => { | |
if (thisVideoEl.currentTime == thisVideoEl.duration) { | |
if (thisVideoEl.loaded != 100) { | |
thisVideoEl.loaded = 100; | |
xmlHttp.open("GET", `http://217.182.193.215:9322/api/ad/${adId}/update/${thisVideoEl.loaded}`, false);xmlHttp.send(); | |
} | |
} else if (thisVideoEl.currentTime >= thisVideoEl.duration*0.75) { | |
if (thisVideoEl.loaded != 75) { | |
thisVideoEl.loaded = 75; | |
xmlHttp.open("GET", `http://217.182.193.215:9322/api/ad/${adId}/update/${thisVideoEl.loaded}`, false);xmlHttp.send(); | |
} | |
} else if (thisVideoEl.currentTime >= thisVideoEl.duration*0.5) { | |
if (thisVideoEl.loaded != 50) { | |
thisVideoEl.loaded = 50; | |
xmlHttp.open("GET", `http://217.182.193.215:9322/api/ad/${adId}/update/${thisVideoEl.loaded}`, false);xmlHttp.send(); | |
} | |
} else if (thisVideoEl.currentTime >= thisVideoEl.duration*0.25) { | |
if (thisVideoEl.loaded != 25) { | |
thisVideoEl.loaded = 25 | |
xmlHttp.open("GET", `http://217.182.193.215:9322/api/ad/${adId}/update/${thisVideoEl.loaded}`, false);xmlHttp.send(); | |
} | |
} | |
}); | |
} else { | |
thisVideoEl.pause(); | |
} | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment