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();
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:
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
Don't attempt to set innerHTML like that; you'll bust the page (Event listeners will get trashed, etc.).
unsafeWindow is a non issue here, and is not needed.
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.
Related
I'm trying to help a good friend out with his site. I did not make this site so I'm diving into the deep, I am also new with WP. He wants a new audio player and Ajax pagination.
So far I did everything manually. It's a rough start though. I just load the next page with Ajax and fetch a div from that page.
My problem is: all posts contain a Facebook Like button and a Tweet button at the bottom. Now when I load the next page of posts (the div), those buttons disappear. I guess it has to do with plugins that are being loaded when the page itself is loaded. It is also missing the number of comments. These are Facebook comments also. To be honest I have no idea how to fix this...
Edit: Ok, I'm pretty sure I somehow need to reload that plugin in the Javascript chain... is that possible?
You can check it out at
Is there a better way? Am I actually doing it right? Is there a plugin that makes this easier? Again, I did not make this site and it's my first time using WP. I have no idea where to find the page settings (which might contain the max posts per page etc.)
Thanks in advance, I hope I am clear, if not, please say.
What you need to do is refresh the Facebook plugins after loading dynamic content with Ajax. Here's a snippet of code I used on a project:
// Run this on your Ajax callback
try{
// This code reloads the Facebook plugins
FB.XFBML.parse();
}
catch(ex){
// Something went wrong
}
The code requires you to load the Facebook API (duh!).
I am replacing the showModalDialog function which no longer works in Chrome and FF. We have many applications using that. The problem is, pop up windows do post instructions to the web server and update the database. For instance if there's a list of accounts on screen and edit is clicked on one of the accounts, an edit page appears as a pop up, posts changes back to the web server, then the list is refreshed with changes. The entire list may be refreshed or just text that changed.
I made a javascript function to do pop up content using overlays. I thought it would be simple to replace showModalDialog calls with the javascript function, but I did not consider post instructions sent by the pop up page to update the database, and complexity to facilitate that. Posting can be done via ajax-like functionality, encapsulated in a set of functions. Before I start writing code to do this I'd like to know what other people have done in this circumstance. Thanks
I wrote some javascript to do everything I want. Since my pop up windows had javascript, I needed to run javascript upon rendering modal content, and also when the modal content went away. This will produce any number of overlays on top of each other, managing each. Content can optionally appear in a frame with a title bar, closely matching the functionality of showModalDialog.
Download at http://bikehappy.org/modal.html . If used, please give feedback saying if it works and provide update suggestions.
So I've scoured the internet for a way to hide the url at the bottom of a page printed using window.print, and it seems the only way to do it is for the user to disable the option in their page settings.
Not ideal, I'm trying to hide the address to our serviceNOW instance from being printed on a form that will be given to our clients customers.
So with hiding it out of the question is there a way I can mask it to say something other than the actual url?
I'm not sure but I think solution 3 here is doing something like this
http://www.codeproject.com/Questions/424312/Can-anyone-help-me-to-hide-Header-Footer-and-Page
But I don't understand that at all.
Is it possible to fool the print dialog into thinking we are on a different page without actually redirecting?
btw I don't see it being useful for this solution but I cannot use jQuery (so many things would have been easier if I could) for some reason it will not work in our ServiceNOW instance.
I'm using the .prepend() action into a page when a user click on a button.
I think only the clicker can see the element being added into the list but what do for all the users already watching this page can also see it ?
PS : A good example is the friend news thread of facebook (in the right column) where one actuality appears for everybody.
DOM operations are purely in YOUR browser. Unless your JS code pings the server with an update on the actions, and your server pushes that data to any observers, there's no way for one user's browser to 'spy' on what another's is doing.
When you say other users, do you mean other users of the site?
If so then the answer is no. Only that user will see ANY change made to the DOM in javascript because the change is only happening on the local computer. This is true regardless of whether AJAX is used.
Here's a metaphor to help you understand. When a web site gives a user a page, it is like mailing a letter to that user. The person who receives the letter (html document) can make changes all day long and it won't affect anyone else who got a copy of that letter.
You misunderstand jQuery prepend(). It does not perform any AJAX. It will simply insert new HTML on the page. If it is passed an existing HTML element, it will move that element to the beginning of element that you are prepending to.
For example:
// this adds a new paragraph to the beginning of the main content div
$('#mainContentDiv').prepend('<p>New content</p>');
See the jQuery API for more info: jQuery .prepend()
Notice you will not find AJAX mentioned anywhere on the page except in a comment by Karl Swedberg, and he refers to the AJAX docs.
You will probably need to use something like jQuery.ajax() separate from .prepend() to make the server update for other users to receive the change.
I was searching for a script or at least a code snippet but haven't really made any progress. Anyway, I'm looking for a script that works like a simple pagination javascript but it should be accessible by linking from anywhere in the document and by calling it with the URL (e.g. on www.abc.de/default.html#thirddiv the third page of the pagination is displayed). Further, the contents should be loaded upon request (when the user clicks on the link and enters the specific page of the pagination), so that cookies, that have been set or deleted in the same document earlier can be used later without reloading the entire page. Something like that is used on Facebook for calling contents and loading them.
I've found a script on CSS Tricks called BetterBlogroll but I don't really get my mind into this. A pagination script from DynamicDrive is already working very well on the page but my problem is that there should be running three of them on the same page and as I said, the content should be loaded upon the user's request.
The script I'd need does not has to be with loads of CSS, the best way would be plain javascript and only the required CSS and HTML data. Anything else just disturbs. If anyone can help me out here, I'd be very thankful.
Check out Ryan Bates's Railscasts #174 and #175. These two are not rails specific, and explain this well.