Live data from Hacker News

Will you drown?

game.notch.net

51–60 of 145 posts

Re: Will you drown?

#51
post #32

Earlier quoted context omitted.

Seriously? window.setInterval(function(){ Array.prototype.forEach.call(document.querySelectorAll('a'),function(i) {i.dispatchEvent(event)})},1000);

I was going for quick and dirty. $(foo).click() was available so why not use it?

It was a joke...

Re: Will you drown?

#56
post #4

Play automatically: setInterval(function(){ $("a").click() }, 100) (Edit: Yes, this leads you through a very fast, very bad life. Play manually and have a better life.)

nope, that wont work at all. Even if you add jquery manually, this won't work at all. The correct one should be

  fireEvent = function(element){
   var event; // The custom event that will be created

    if (document.createEvent) {
    event = document.createEvent("HTMLEvents");
    event.initEvent("click", true, true);
    } else {
    event = document.createEventObject();
    event.eventType = "click";
    }

    event.eventName = "name-of-custom-event";

    if (document.createEvent) {
    element.dispatchEvent(event);
    } else {
    element.fireEvent("on" + event.eventType, event);
    }
  }

  setInterval(function(){
     Array.prototype.forEach.call(document.querySelectorAll('a'),function(d){
      fireEvent(d);
     })
  }, 1000);

Re: Will you drown?

#57
post #56
post #4

Play automatically: setInterval(function(){ $("a").click() }, 100) (Edit: Yes, this leads you through a very fast, very bad life. Play manually and have a better life.)

nope, that wont work at all. Even if you add jquery manually, this won't work at all. The correct one should be fireEvent = function(element){ var event; // The custom event that will be created if (document.createEvent) { event = document.createEvent("HTMLEvents"); event.initEvent("click", true, true); } else { event = document.createEventObject(); event.eventType = "click"; } event.eventName = "name-of-custom-event…

[deleted]

Re: Will you drown?

#58
post #56
post #4

Play automatically: setInterval(function(){ $("a").click() }, 100) (Edit: Yes, this leads you through a very fast, very bad life. Play manually and have a better life.)

nope, that wont work at all. Even if you add jquery manually, this won't work at all. The correct one should be fireEvent = function(element){ var event; // The custom event that will be created if (document.createEvent) { event = document.createEvent("HTMLEvents"); event.initEvent("click", true, true); } else { event = document.createEventObject(); event.eventType = "click"; } event.eventName = "name-of-custom-event…

Quick to call someone stupid, aren't we? Did you even try his code? Go try it. Just because a site doesn't have jQuery, doesn't mean $ isn't assigned to anything.
Post reply on HN