milkytiptoe / Name-Sync

Enables names on 4chan's forced anon boards
http://milkytiptoe.github.io/Name-Sync/
Other
18 stars 5 forks source link

Trigger event on sync #38

Closed ErinSteph closed 11 years ago

ErinSteph commented 11 years ago

I though I'd best make this as an issue rather than a pull request because I'm not great with this stuff, and in every likelyhood it probably already does something like this I haven't noticed, I'm sorry if I'm killing github etiquette or anything. Could we have so it triggers an event on sync? Maybe $(document).trigger('namesSynced'); or something, something for other scripts to listen for after names are updated. Somewhat like how with 4chan X we can add an event listener for 'ThreadUpdate' to trigger things when new posts are appended.

ihavenoface commented 11 years ago

Should be possible. Just the event with nothing passed, right?

ErinSteph commented 11 years ago

That would be perfect, thanks c:

milkytiptoe commented 11 years ago

Why?

ErinSteph commented 11 years ago

I have a script that modifies posts on page, this became something I'd use at first when I added a function that turns names into uniquely colored capcodes, but I'd use it for a lot more now. Basically, the way I was doing it, was looping every 2 seconds to check if names had been updated and rerunning the function if so, it would be much easier if I could just have it listen for namesync pushing an event and updating then.

milkytiptoe commented 11 years ago

Alright.

ErinSteph commented 11 years ago

awesome, thank you!

milkytiptoe commented 11 years ago

For use:

document.addEventListener('NamesSynced', function() {
  // Magic happens
});
ErinSteph commented 11 years ago

you're amazing, thank you so much ♥