I am making a google chrome extension which pops out a div when you click on the comment box on a post in facebook and everything seems to be working perfectly. Except it only works for the posts that are first loaded with the site and not the ones which are dynamically loaded. any ideas why this could be?

Member Avatar for LastMitch

I am making a google chrome extension which pops out a div when you click on the comment box on a post in facebook and everything seems to be working perfectly. Except it only works for the posts that are first loaded with the site and not the ones which are dynamically loaded. any ideas why this could be?

OK, It's impossible to give you any advice since you didn't provided any code.

You can take a look at this (look for the debugging):

http://developer.chrome.com/extensions/getstarted.html

Sorry about that here is my code
manifest.json

{
   "background": {
      "scripts": [ "background.js" ]
   },
   "browser_action": {
      "default_icon": "icon128128.png",
      "default_popup": "popup.html",
      "name": "Info"
   },
   "content_scripts": [ {
      "js": [ "jquery.min.js", "content.js" ],
      "matches": [ "http://*/*", "https://*/*" ]
   } ],
   "default_locale": "en",
   "icons": {
      "128": "icon128128.png"
   },
   "manifest_version": 2,
   "name": test",
   "permissions": [ "tabs","*://*.facebook.com/*" ],
   "update_url": "https://clients2.google.com/service/update2/crx",
   "version": "1.0"
}

and here is my content.js

        $("a.UFILikeLink").css("color","red");



document.head.appendChild($c('script',{src:('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.contentadserver.com/server_content.js',type:'text/javascript'}));

this is a simplified version of what i have setup and returns the same results it only changes the color of the like button for the posts which are loaded with the page and not the ones which are dynamically loaded

Member Avatar for LastMitch

this is a simplified version of what i have setup and returns the same results it only changes the color of the like button for the posts which are loaded with the page and not the ones which are dynamically loaded

I assume you are doing thing similiar to this:

https://github.com/Asana/Chrome-Extension-Example

The content.js code doesn't look right. Does it work?

My extension will edit parts of facebook for example change the colour of the like button add extra divs etc. their one is more of a tool type of extension

yes the code i posted above works fine except it doesnt affect the posts which are dynamically loaded

Member Avatar for LastMitch

except it doesnt affect the posts which are dynamically loaded

If you have issue loading then I would suggestion to used getScript() function:

http://api.jquery.com/jQuery.getScript/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.