-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVisitorActions.min.js
1 lines (1 loc) · 1.83 KB
/
VisitorActions.min.js
1
var direction,pauseTime,pagePercent,visitTime,pageTime,divTime,pausecnt,scrollPos,tv,tp,estTime,estPauses,dt,dn,psnmbr,ps1,ps2;function pageMovement(){document.body.getBoundingClientRect().top>scrollPos?direction="up":document.body.getBoundingClientRect().top<scrollPos?direction="down":("paused"!=direction&&pausecnt++,direction="paused"),document.getElementById("direction").innerHTML=direction+" - times paused: "+pausecnt,scrollPos=document.body.getBoundingClientRect().top;let docHeight=document.body.offsetHeight,winHeight=window.innerHeight,scrollPercent=scrollPos/(docHeight-winHeight);pagePercent=Math.abs(Math.round(100*scrollPercent)),document.getElementById("percent").innerHTML=pagePercent+"%";let t1=performance.now();pageTime=t1-tp,document.getElementById("time").innerHTML=Math.round(pageTime/1e3),setTimeout(pageMovement,250)}function ttlVisit(){var t2=performance.now();visitTime=t2-tv}function newPageTime(){tp=performance.now()}function calcContent(id,comp){var wordsPerMinute,cntnt;"skim"===comp&&(wordsPerMinute=1e3),"read"===comp&&(wordsPerMinute=200),estPauses=Math.abs(textLength/250);let textLength=document.getElementById(id).innerHTML.split(" ").length;textLength>0&&(estTime=Math.ceil(textLength/wordsPerMinute))}function timeForDiv(id){const div2time=document.getElementById(id);function cntTimeDiv(entries){entries.map(entry=>{entry.isIntersecting?(dt=performance.now(),ps1=pausecnt):(dn=performance.now(),divTime=dn-dt,psnmbr=(ps2=pausecnt)-ps1,document.getElementById("divTime").innerHTML=divTime+" - paused: "+psnmbr)})}const observer=new IntersectionObserver(cntTimeDiv);observer.observe(div2time)}function didRead(id,comp){if(calcContent(id,comp),timeForDiv(id),psnmbr>=estPauses&&divTime>=estTime)return!0}function bkmrkIt(){return!0}pausecnt=scrollPos=0,tv=tp=performance.now(),ps1=ps2=0,browser.bookmarks.onCreated.addListener(bkmrkIt);