0

I'm creating a Chrome extension for a website that has no open API, so I'm stuck reading Closure Compiled spaghetti code for a long time. I've made a lot of progress but I seem to be stuck. On the page's onload, this function executes:

function comments_initReply(){
    var b=$("#ajax_comm div.com");
    for(var a=0;a<b.length;a++){var d=$(b[a]);
    var c=d.find(".commentReplyLink");
    if(c.length){
        d.on("dblclick",function(){$(this).closest("div.com").find(".commentReplyLink").click()}).find(".t")}
    }
} 

What it does is it takes a comment div on a website and it makes it into a large double-clickable area for you to open a reply. All I want to do is remove the double-clicking property so you can double-click text and highlight it instead of opening a reply modal dialog.

Since the function is anonymous, it cannot using removeEventListener to detach it. Any ideas? I prefer to not use jQuery.

7
  • It looks as though that event handler was attached through jQuery. It would probably be easiest also to remove it with jQuery... Commented Apr 4, 2014 at 5:47
  • "I prefer to not use jQuery." - Why? Commented Apr 4, 2014 at 5:49
  • If jQuery is just Javascript, I'd prefer to write out one whole function from the library than including the entire library, which I won't be finding myself using. Commented Apr 4, 2014 at 5:51
  • The jQuery library is already included in your project, since this function you posted is jQuery-based. Commented Apr 4, 2014 at 5:54
  • It's not in the project, it just happens to interact with the jQuery in the site because in order to directly modify the JS of the page, I must inject my own JS through the content script. Commented Apr 4, 2014 at 6:03

1 Answer 1

1

Well, although you prefer not to use jQuery, it's much easier to use it, and my solution here will be jQuery-based, and feel free to convert it into a normal Javascript, if you want to.

function comments_endReply() {
    $("#ajax_comm div.com").off("dblclick");
}
Sign up to request clarification or add additional context in comments.

2 Comments

I appreciate the response. It does work. I guess I might just use it, I seem to have some irrational fear of jQuery.
I'm not sure that fear is entirely irrational. But in the end, if you want someone to clean up a mess, who better than the one who made the mess in the first place?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.