I’m trying to create a chrome extension which shows tweets with hashtag perkytweets in the extension pop up but nothing is showing up.
Here is the manifest.json code
{
"name": "My First Extension",
"version": "1.0",
"manifest_version": 2,
"description": "The first extension that I made.",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
}
}
Here is the popup.html code
<html>
<head>
<title>Getting Started Extension's Popup</title>
<style>
body {
min-width:357px;
overflow-x:hidden;
}
img {
margin:5px;
border:2px solid black;
vertical-align:middle;
width:75px;
height:75px;
}
</style>
<script src="script.js"></script>
</head>
<body>
</body>
</html>
Here is the script.js code
var req = new XMLHttpRequest();
req.open(
"GET",
"http://search.twitter.com/search.atom?q=perkytweets",
true);
req.onload = showTweets;
req.send(null);
function showTweets()
{
document.body.appendChild(req.responseXML);
}
You need to fire of the request only when the document has been loaded. try wrapping your code in an
onloadhandlerUPDATE
You need to allow access to the twitter URL, add this to your manifest:
So your
manifest.jsonwill now look like this:UPDATE
req.responseXMLis not an Element yet, and as such cannot be directly appended to the body,console.logyour result and go from there.