Getting The Source Code Of A Page From A Googlechrome Extension
I am writting an extension for googlechrome to display a list of items from a website. The problem I have is that I cannot get the source code of the page I am looking for. When I
Solution 1:
It's all described in details here. Long story short:
- Declare domain permissions in the manifest.
- Make cross-domain request from a background page.
- Transfer results to a content script using message passing, if needed.
UPDATE
Here is code that works for me:
Manifest - exactly as yours.
popup.html:
<html><head><script>var xhr = newXMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
alert(xhr.status);
if (xhr.status == 200) {
alert(xhr.responseText);
}
}
}
var url = "http://search.twitter.com/trends/current.json?exclude=hashtags";
xhr.open("GET", url, true);
xhr.send();
</script></head><body></body></html>
Solution 2:
can you run the site in an iframe and then use some javascript to run:
sourceCode=[iframename].document.body.parentNode.innerHTML;sourceCode='<html>'+sourceCode+'</html>'
I don't know if this works across domains
Post a Comment for "Getting The Source Code Of A Page From A Googlechrome Extension"