Code: Select all
javascript: (function() { for(var i = 1; i <= 52; ++i) delayed(i); function delayed(i) { setTimeout(function() { console.log(i); }, 0); } })();
Code: Select all
(function() {
for(var i = 1; i <= 52; ++i)
delayed(i);
function delayed(i) {
setTimeout(function() {
console.log(i);
}, 0);
}
})();
For pages with enabled JavaScript:
1 ... 52
With disabled JavaScript:
52 ... 3
(only last 49!)
noscript-2.5.6-sm+fx+fn.xpi\components\noscriptService.js
Code: Select all
while (tt.length && count++ < 50) { // let's prevent infinite pseudo-loops
tt.sort(function(b, a) { return a.d < b.d ? -1 : (a.d > b.d ? 1 : 0); });
t = tt.pop();
t.f.call(window, t.a);
}
And this is very simple way to do something pseudo asynchronously:
Code: Select all
Array.forEach(
document.getElementsByTagName("*"),
function processAsync(item) {
setTimeout(function() {
process(item); // Something slow
}, 0);
}
);
Code: Select all
var delayed = {
maxActive: 15,
active: 0,
queue: [],
add: function(func, args) {
if(this.active >= this.maxActive) {
console.log("wait...");
this.queue.push(arguments);
return;
}
++this.active;
var _this = this;
setTimeout(function() {
_this.next(--_this.active);
func.apply(window, args);
}, 0);
},
next: function(cnt) {
while(cnt++ < this.maxActive && this.queue.length)
this.add.apply(this, this.queue.shift());
}
};
function processAsync(item) {
delayed.add(process, arguments);
}
https://github.com/Infocatcher/Bookmark ... rs.js#L171
https://github.com/Infocatcher/UserScri ... er.js#L353
P.S. I get
forOoops, something in your posting triggered my antispam filter...
Please use the "Back" button to modify your content and retry.
Code: Select all
Tools \– Web Developer \– Web Console
