mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 00:52:16 -06:00
prevent massive stacks in chrome
This commit is contained in:
parent
ed5f6736df
commit
f0125cdc36
|
@ -21,7 +21,6 @@ function main() {
|
|||
}
|
||||
|
||||
function collect() {
|
||||
setTimeout(collect, interval * 1000);
|
||||
try {
|
||||
var pd = document.querySelector('ytd-watch-flexy');
|
||||
if (!pd)
|
||||
|
@ -39,7 +38,7 @@ function main() {
|
|||
console.log("[yt-pdh]", ex);
|
||||
}
|
||||
}
|
||||
collect();
|
||||
setInterval(collect, interval * 1000);
|
||||
}
|
||||
|
||||
var scr = document.createElement('script');
|
||||
|
|
|
@ -921,14 +921,16 @@ function playpause(e) {
|
|||
var mpui = (function () {
|
||||
var r = {},
|
||||
nth = 0,
|
||||
timeout = null,
|
||||
preloaded = null;
|
||||
|
||||
r.progress_updater = function () {
|
||||
clearTimeout(timeout);
|
||||
timer.add(updater_impl, true);
|
||||
};
|
||||
|
||||
function updater_impl() {
|
||||
if (!mp.au) {
|
||||
widget.paused(true);
|
||||
timer.rm(updater_impl);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -970,9 +972,9 @@ var mpui = (function () {
|
|||
}
|
||||
}
|
||||
|
||||
if (!mp.au.paused)
|
||||
timeout = setTimeout(r.progress_updater, 100);
|
||||
};
|
||||
if (mp.au.paused)
|
||||
timer.rm(updater_impl);
|
||||
}
|
||||
r.progress_updater();
|
||||
return r;
|
||||
})();
|
||||
|
@ -2822,7 +2824,7 @@ var treectl = (function () {
|
|||
}
|
||||
|
||||
function onscroll() {
|
||||
if (!entreed || treectl.hidden)
|
||||
if (!entreed || treectl.hidden || document.visibilityState == 'hidden')
|
||||
return;
|
||||
|
||||
var tree = ebi('tree'),
|
||||
|
@ -2858,12 +2860,7 @@ var treectl = (function () {
|
|||
tree.style.height = treeh < 10 ? '' : treeh + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
function periodic() {
|
||||
onscroll();
|
||||
setTimeout(periodic, document.visibilityState ? 100 : 5000);
|
||||
}
|
||||
periodic();
|
||||
timer.add(onscroll, true);
|
||||
|
||||
function onresize(e) {
|
||||
if (!entreed || treectl.hidden)
|
||||
|
|
|
@ -929,21 +929,17 @@ function up2k_init(subtle) {
|
|||
}
|
||||
|
||||
var tasker = (function () {
|
||||
var tto = null,
|
||||
running = false,
|
||||
var running = false,
|
||||
was_busy = false;
|
||||
|
||||
function defer() {
|
||||
running = false;
|
||||
clearTimeout(tto);
|
||||
tto = setTimeout(taskerd, 100);
|
||||
}
|
||||
|
||||
function taskerd() {
|
||||
if (running)
|
||||
return;
|
||||
|
||||
clearTimeout(tto);
|
||||
if (crashed)
|
||||
return defer();
|
||||
|
||||
|
@ -1034,7 +1030,7 @@ function up2k_init(subtle) {
|
|||
return defer();
|
||||
}
|
||||
}
|
||||
taskerd();
|
||||
timer.add(taskerd, true);
|
||||
return taskerd;
|
||||
})();
|
||||
|
||||
|
|
|
@ -555,6 +555,39 @@ function hist_replace(url) {
|
|||
}
|
||||
|
||||
|
||||
var timer = (function () {
|
||||
var r = {};
|
||||
r.q = [];
|
||||
r.last = 0;
|
||||
|
||||
r.add = function (fun, run) {
|
||||
r.rm(fun);
|
||||
r.q.push(fun);
|
||||
|
||||
if (run)
|
||||
fun();
|
||||
};
|
||||
|
||||
r.rm = function (fun) {
|
||||
apop(r.q, fun);
|
||||
};
|
||||
|
||||
function impl() {
|
||||
if (Date.now() - r.last < 69)
|
||||
return;
|
||||
|
||||
var q = r.q.slice(0);
|
||||
for (var a = 0; a < q.length; a++)
|
||||
q[a]();
|
||||
|
||||
r.last = Date.now();
|
||||
}
|
||||
setInterval(impl, 100);
|
||||
|
||||
return r;
|
||||
})();
|
||||
|
||||
|
||||
var tt = (function () {
|
||||
var r = {
|
||||
"tt": mknod("div"),
|
||||
|
|
Loading…
Reference in a new issue