Created
March 10, 2010 11:49
-
-
Save mala/327794 to your computer and use it in GitHub Desktop.
presen to jpg extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<script type="text/javascript"> | |
chrome.browserAction.onClicked.addListener(function(tab){ | |
capture(); | |
}); | |
function capture(){ | |
chrome.windows.getCurrent(function(w){ | |
chrome.tabs.captureVisibleTab(w.id, function(d){ | |
send_data(d); | |
chrome.tabs.getSelected(w.id, function(tab) { | |
/* your custom code here */ | |
chrome.tabs.update(tab.id, | |
{ url: "javascript:Presen.next();void(0);" } | |
); | |
}); | |
}) | |
}) | |
} | |
function send_data(data) { | |
var req = new XMLHttpRequest; | |
req.open("POST", "http://127.0.0.1:8080/recieve"); | |
req.send(data); | |
} | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "capture screenshot", | |
"description": "capture screenshot", | |
"version": "0.0.1", | |
"background_page": "background.html", | |
"permissions": [ | |
"tabs", | |
"http://*/*", | |
"https://*/*" | |
], | |
"browser_action": { | |
"default_title": "capture", | |
"default_icon": "capture.png" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/ruby | |
require 'webrick' | |
require 'fileutils' | |
require 'date' | |
require 'base64' | |
HTTP_OPTIONS = { | |
:Port => 8080, | |
:RequestTimeout => 60, | |
} | |
count = 0 | |
recv_handler = Proc.new() {|req,res| | |
img = req.body | |
img.sub!('data:image/jpg;base64,', '') | |
open("./img/#{count}.jpg", "w") do |f| | |
f.binmode | |
f.print Base64.decode64(img) | |
f.close | |
end | |
count = count + 1 | |
res.status = 200 | |
res.body = 'SCREEN SHOT SERVER' | |
} | |
s = WEBrick::HTTPServer.new(HTTP_OPTIONS) | |
Signal.trap('INT') do | |
s.shutdown | |
end | |
s.mount_proc('/recieve', recv_handler) | |
s.start | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment