cfinke / Comment-Snob

Comment Snob is a browser extension that filters out undesirable comments from comment threads on the Web.
GNU General Public License v2.0
6 stars 0 forks source link

ajaxInitiatorSelector Issue #1

Closed patrickgalbraith closed 13 years ago

patrickgalbraith commented 13 years ago

I am trying to set up a filter for GomTV.net it works fine when the page first loads. However when the "View More Comments" button (found at the bottom of the page) is pressed none of the new comments are filtered. As you can see I have the dynamic option set to true, but I have tried with it set to false.

Another likely related issue is that if you click the "hide comments" link then click to show the comments again they will no longer be filtered.

Here is a sample page: http://www.gomtv.net/2011gslsponsors4/vod/65741

And the filter I am using:

{ "id":"gomtvnet@hamradio", "label":"GomTV.net", "url":"^http://www.gomtv\\.net/", "allCommentsSelector":"#reply", "commentContainerSelector":"#gomChat li", "commentTextSelector":".status-body", "commentHideSelector":"> *", "statusPlacement":"before", "statusElementTag":"div", "statusElementAttributes":{ "class":"status-content" }, "ajaxInitiatorSelector":".comment_control, .comment_control a, #btnMore, a.expand_list", "dynamic":true }

patrickgalbraith commented 13 years ago

Ok I fixed the issue myself but it requires a patch to content.js. Basically just added an event listener for DOMNodeInserted.

Change on line 262

        $(theRule.ajaxInitiatorSelector).live("click", function (e) {
            allComments.each(function (idx, el) {
                el.addEventListener("DOMNodeRemoved", refilterComments, false);
                el.addEventListener("DOMNodeInserted", refilterComments, false);
            });
        });

Change on line 280:

function doRefilterComments() {
    $(theRule.allCommentsSelector).each(function (idx, el) {
        el.removeEventListener("DOMNodeRemoved", refilterComments, false);
        el.removeEventListener("DOMNodeInserted", refilterComments, false);
    });

    filterComments(true);
}

And the updated filter:

{
   "id":"gomtvnet@hamradio",
   "label":"GomTV.net",
   "url":"^http://www.gomtv\\.net/.*$",
   "allCommentsSelector":"#reply",
   "commentContainerSelector":"#gomChat li",
   "commentTextSelector":".status-body",
   "commentHideSelector":"> *",
   "statusPlacement":"before",
   "statusElementTag":"div",
   "statusElementAttributes":{
      "class":"status-content"
   },
   "ajaxInitiatorSelector":".commnet_off, .commnet_on, .expand_list",
   "dynamic":true
}

Seems to be working really well with that patch.

cfinke commented 13 years ago

Wow, GitHub didn't email me your follow-up comment, and I ended up implementing the exact same patch in version 6, which I just published on the Chrome Web Store. Thanks for the report.

patrickgalbraith commented 13 years ago

Great that you got the fix out thanks for that. Awesome extension by the way, lot of fun to play around with especially the keyword filtering.