Take the 2-minute tour ×

I am trying to execute a simple bit of jQuery or JavaScript once logged in to my Facebook account. The end goal at this moment is to click on my custom feed once the element is visible, rather than having it default to the entire Facebook friend feed.

On trying to code this using my Developer's Console in Chrome no JavaScript/jQuery seems to work at all. Even just a simple $('div'); returns null. Is it possible to run code on Facebook's page? What are they doing differently?

I guess the end goal would be to click a div if the .val('give a waffle'); but just understanding why it has not worked until now would also be interesting.

Any hints, tips or suggestions are more than welcome.

share|improve this question
um....whats the purpose of this? –  Henesnarfel Feb 7 '12 at 21:31
Are you developing a FB app? If so the apps are contained in an iFrame and you can use whatever you like - jQuery, JavaScript, whatever. I've done some FB development and have had no problems using their APIs as well as jQuery to achieve whatever I needed. However, in your case I don't know enough about what you're doing to know if it is even referring to an FB app or if you're trying to paste jQuery snippets into form elements in your profile... In short, can you clarify in your question? Maybe being more specific might give some insight into how to help you. –  Kai Qing Feb 7 '12 at 21:33
of course you can execute js in the console window of your browser while on facebook. –  Peter Kelly Feb 7 '12 at 21:34
Hi, Thanks for taking your time to answer my question. I am just playing with my own version of Facebook to be honest. I have set up a custom news feed, consisting of friends i wish to hear about, and constantly have to click on that to view it and i'd like that to be the default. Therefore I just want "on Facebook.com load > click CustomNewsFeed button" so that I can skip the entire newsfeed and basically filter out the rubbish.. –  Georgejnr Feb 8 '12 at 22:34
add comment

1 Answer

up vote 5 down vote accepted

Facebook doesn't use jQuery, if you want to play with their page using jQuery commands you'll need to load it. Just copy the contents of http://code.jquery.com/jquery-1.7.1.min.js and paste it into your console first. Then proceed as usual.

Additionally you could let Google host your jQuery :

<script type="text/javascript"
<script type="text/javascript">
  $(document).ready(function() {
    // This is more like it!

Many sites do this so the chances of your user already having the library cached is relatively high.

share|improve this answer
Thanks Sinetheta. Worked like a charm –  Georgejnr Feb 7 '12 at 21:55
add comment

Your Answer


