So I am trying build an extension in Chrome that will parse FaceBook HTML for images posted only in "comments" and extract these images to the popup for downloading.
Assuming that the user will only call the extension from a Chrome tab carrying an appropriate Facebook page, I have attempted to retrieve the source html of the open tab via the following implementation: Getting the source HTML of the current page from chrome extension
Extracting the HTML to the popup via:
function getImages(HTML) {
$('.UFICommentContentBlock', HTML).find('a[rel="theater"]').find("img").
each( function() {
var img = document.createElement('img');
img.src = $(this).attr("src");
document.body.appendChild(img);
});
}
where "HTML" is the parsed HTML string extracted from the Chrome extension.
However, although this implementation works in grabbing the images that I want, it also grabs images that are no longer present in the HTML on the open Chrome tab. When I log the extracted HTML to the console, I notice that it does not quite match up with the HTML I find when I "view page source" on the open Chrome tab. In fact, the extracted HTML makes reference to images that I had previously extracted with my extension but that are not present on the Chrome tab from which I am currently extracting.
If possible, could someone please explain why my HTML extraction might be pulling this old HTML and perhaps offer a possible fix/alternative implementation?
Aucun commentaire:
Enregistrer un commentaire