Piperita / ID_modding

Add-ons for DarknessKight's PonyDebate-script. 'LinkPreview' adds buttons to links that open/close previews for their content. The "Filter"-folder contains a script circumventing ID's filter to automatically catch and replace banned words. "Padding" is a simple script taking care of unreadable posts due to too many replies. The folder "CountReplies" is a stand-alone function for bluefury to store replies with author and text in a csv-file
0 stars 0 forks source link

Counting replies could be faster using IntenseDebate API #3

Open Darknesskight opened 9 years ago

Darknesskight commented 9 years ago

You mentioned that you had issues with knowing when comments are loaded. I have already solved this in PonyDebate as I needed to know when to place refresh buttons. I created a gist for you to look at so that you can have the counting go by much faster. I hope it helps you out.

Counting comment threads

You can see other api options available to you here. You can view PonyDebate or ask me on how to use them. IntenseDebate hooks and filters

Piperita commented 9 years ago

Thanks Kight, this really speeds the process up :)

There is a small bug with your code though, it is only launchable twice before it triggers the else-clause after every second ID-page until the EQD-page is reset. This happens both with your code as posted and the code when put into functions.

For this function it isn't that noticable because it mostly gets only launched once anyway but it might affect other codes where this function is used in.

Darknesskight commented 9 years ago

Hmm. Its probably because I didn't remove it out of the array properly. I was thinking about it this morning and just setting the value to undefined will not work as the length of the array stays the same. Trying doing the below and see if that fixes it. I can take an extra look at it when I get home.

Replace id_action_list['page_load'][lastAction] = undefined with id_action_list['page_load'].pop();

Piperita commented 9 years ago

Yap, that works.

Thanks a lot :)

Darknesskight commented 9 years ago

No problem. I will need to double check but ID may not append the functions to the end of the array or may be reorganizing it after adding the function. Pop may not work if ID does either of the previously mentioned things. I will update this issue when I find out.

Darknesskight commented 9 years ago

I updated the gist with the fix. I moved the inline function code into the count comment function and registered the comment function itself to ID. This allows me to use indexOf to find it and use splice to remove it.

Registering a function:

id_add_action('page_load', countCommentThreads);

Unregistering the function

var commentCountIndex = id_action_list['page_load'].indexOf(countCommentThreads);
id_action_list['page_load'].splice(commentCountIndex, 1);