How to find if web page got appended using chrome extension - facebook

I am new to chrome extension and I am trying to find whether page content got appended.
For E.g. in Facebook, we can see the content will appended automatically when the user scroll down the page.
I have the following code in background.js
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
alert("page is appending....");
});
The above code is expected to fire when the page got updated. But, I am seeing that it is getting called only for few times. Not always.
Or Am I making any mistake here ?
My requirement is, whenever the web page appended in facebook, I have to do get the page content and obtain few string from the same.
Thanks in advance.

Your onUpdated event is in the chrome.tabs namespace on purpose, it listens the updates of tab's general attributes like: the tab pinned, the favicon changed, the URL changed, see the documentation (also check the update() method). So this way is not workable. Instead listen the DOM tree change with DOMSubtreeModified event or MutationObserver.

Related

Facebook Page Tabs position attribute stopped working

According this Facebook page tab documentation you can update the 'position' of the Tab by calling a http post as follows :
https://graph.facebook.com/v2.5/{pageId}/tabs?access_token={pageToken}
At this endpoint you can update a Page tab's position with the POST request, passing the parameter tab=TAB_NAME&position=TAB_POS.
This has stopped working recently (perhaps since Facebook rolled out page templates for Admins).
I am able to update the custom_name and image for the tab. And I can also see the 'position' attribute for the tab is changed to the new value. However the actual position of the Tab on the page does not change. Earlier calling the above post, would actually move the tab within the list of other tabs.
I am looking for help on what is the new way to change the tab position.
Thanks.
Facebook have acknowledged this as a bug on their platform and are close to deploying a fix : https://developers.facebook.com/bugs/1302804313113666/

Facebook Comments with Ember Views in Subroute

I am trying to add the Facebook comment plugin to one of my subroutes, but the problem is that it is only shown when I refresh the page. As soon as I navigate somewhere else (= the view in which I added the snippet is removed) it is gone. Meaning when I navigate back to the same route, the Facebook Plugin is not reinitialized.
Is there a way to prevent it from being destroyed or maybe do some "FB.Init()" on route activation?
If you're using XFBML you can call
FB.XFBML.parse(document.getElementById('foo'));
Or call it without parameters, to do it on the entire page.

Dirrect way to get content of current open page into main.js file in FireFox add-on sdk

I have one problem with add-on Firefox sdk. I'm searching a way to get content of current working page into main.js file. The application is based on widget that open popup when is clicked. I have one idea. To inject content script into open with sdk/page-worker and this content script using port API (self.port.emit) to trigger event and pass document.body.innerHTML. Like this:
self.port.emit("getCurrentPageHtml", document.body.innerHTML);
And into main.js file:
popupName.port.on("getCurrentPageHtml", function (receivedHtml) {
// handle received html
});
But will be very good idea if there is some direct API and avoid this communication.
I would appreciate any advice and tips.
Best regards.
I answer my own question for the second time today. Pity. Apparently there is no direct way to do this. So we can listen for panel event with popuVar.port.on. After this we can use:
// must be required tab api
// https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/tabs
tabs.activeTab.url
and use page-worker on this url https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/page-worker. After this content script of this page worker will trigger event to get html of page. Another option is just made request to url of current page.

Refresh Fb Comments Plugin

I'm trying to add a link to allow a user to refresh the Comments plugin on my page so they can see other posts by other people.
I want to do it without refreshing the full page.
There's a html5 player on the page playing audio, hence me not wanting to interrupt that player.
Currently I'm using the standard -
I've tried the jQuery method of giving the div an id and having a header script which counts to 10 and reloads the div widget, it seems to reload the widget, but it doesn't update the contents of the comments plugin to show other's posts, just ones you've added yourself. To see all the updates you have to refresh the page fully, which I don't want to do.
I'm trying to avoid iFrames because of the height issues and extra scroll bars, etc.
Any ideas would be appreciated
I'm not exactly sure what you're trying to do, but you can use the FB.XFBML.parse method to refresh plugins.
The only thing is that you'll need to first remove the old plugin from the dom, then add the new html5/xfbml placeholders (what you get from the comments plugin page when clicking "get code") and then use the FB.XFBML.parse method.

App name showing incorrectly on the ticker

We have an old name for the app and we want the app to show the correct name on the ticker but we have not been able to do it (it is still showing the old name). We updated the title of the url canvas and submitted it on the debugger and interestingly enough, the title is taken correctly on the https address (it is shown on the debugger page but not in the ticker) but not on the http url. Actually it says for the http that the app has problems with the meta tags. Any idea on how to fix this problem? Thanks a Lot, Gilmer
Go to http://developers.facebook.com/tools/debug
Enter your url in that and try to generate all the information.
If that is not showing any errors in that, then scroll down at the end of the page.
You will find block named as "URLs"
Click on the first link named as: "Graph API:".
This will solve your issue.
In future, if you are going to change any content from your page, then don't forget to do the same process once again.
Thanks!