Skip to content

Instantly share code, notes, and snippets.

@mohamedmansour
Created September 23, 2010 02:33
Show Gist options
  • Save mohamedmansour/592986 to your computer and use it in GitHub Desktop.
Save mohamedmansour/592986 to your computer and use it in GitHub Desktop.
Google Chrome Extension to figure out which image on the page is the largest.
<!DOCTYPE html>
<html>
<head>
<style>
body {
width: 300px;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script>
var i = 0;
function addLink() {
chrome.tabs.captureVisibleTab(null, function(dataUrl) {
var content = document.getElementById('body');
var p = document.createElement('p');
var link = document.createElement('a');
link.setAttribute('href', 'http://www.google.com/search?q=' + i);
link.innerHTML = 'search ' + i;
p.appendChild(link);
content.appendChild(p);
i++;
});
}
$('a').live('click', function(e) {
var href = e.currentTarget.href;
chrome.tabs.getSelected(null,function(tab) {
chrome.tabs.update(tab.id, {url: href});
});
});
</script>
</head>
<body>
<button onclick="addLink(); ">Add Link</button>
<div id="body"> </div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment