[script]

(function (){
var g = {
ac: false,
getOscillator: function(){
var osc = this.ac.createOscillator();
osc.type = “square”;
osc.frequency.value = 40;
osc.connect(this.ac.destination);
return osc;
},
init: function (){
if (!this.ac){
this.ac = new AudioContext();
};
this.startCounter();
return this;
},
click: function (){
var osc = this.getOscillator();
osc.start();
setTimeout(()=>{
osc.stop();
}, 3);
},
chance: 0.1,
started: false,
startCounter: function (){
if (this.started){
return this;
}
this.started = true; this.skipsome = 0;
setInterval(() => {
this.verticalScrollToRadiation();
if (Math.random() < this.chance){
this.click();

}
}, 50);
return this;
},
verticalScrollToRadiation: function (){
var ph = this.getPageHeight();
var wh = window.innerHeight;
var totalScroll = Math.max(1200, ph – wh)-400;
var currentScroll = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
this.chance = 0.12 + (currentScroll/totalScroll)*0.92;
console.log(‘tc’, totalScroll, ‘cs’, currentScroll, ‘ph’, ph, ‘wh’, wh, ‘ch’, this.chance);

},
getPageHeight: function (){
var body = document.body,
html = document.documentElement;

return Math.max(
body.scrollHeight,
body.offsetHeight,
html.clientHeight,
html.scrollHeight,
html.offsetHeight
);
}
};
g.init();
})();

 

[/script]

facebooktwittergoogle_plusredditpinterestlinkedinmail