Question

I'm trying to hide specific people in the Facebook sidebar chat list.

My first attempt was to just try and replace the name of a user in the chat bar but a simple .replace doesn't work since the chat bar loads separately, and long after the page itself has loaded.

Is there any way of running the Greasemonkey script after the chat has loaded?

I've heard some about the unsafeWindow functionality, but I'm not sure if I can apply that here, and if so, how.

unsafeWindow.hidePerson = function() {
    document.body.innerHTML = document.body.innerHTML.replace(/Firstname Lastname/g, '' );
}

unsafeWindow.hidePerson();
Was it helpful?

Solution

To answer the question about "Running scripts after internal scripts are fully loaded", see this answer (the question scenario is the same as an AJAX scenario).


However, several things in your case:

  1. Your issue, "I'm trying to hide specific people in the Facebook sidebar chat list", is already covered by Facebook!

    See "Can I turn chat on for just a few friends?"
    Follow the instructions there, and you can:

    • Hide just the people you specify
    • Or, show only the people you designate
    • Or, turn chat off completely

  2. Don't attempt to set innerHTML like that; you'll bust the page (Event listeners will get trashed, etc.).

  3. unsafeWindow is a non issue here, and is not needed.

  4. If you mean something that I haven't covered, see this page, this page, and this page.

    Then edit your question (or ask a new one), and include, at a minimum, the HTML snippet of the part of chat you want to affect, and screenshots of the same.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top