我想编写一个简单的 chrome 扩展,以替代我在大学时必须经常执行的以下步骤序列:
- 截取某些内容
- 在“画图”中编辑屏幕截图
- 将 unnamend.png 保存到硬盘
- 上传 unnamed.png 到 imageshack.us/pic-upload.de 或任何
其他网站
- 与他人分享图片链接。
我不在乎使用哪个图像上传服务,我只是想自动化这个用例以节省时间(我已经红了,做了一个入门 chrome 扩展并检查了他们的 API,但就是这样,这个页面: http: //farter.users.sourceforge.net/blog/2010/11/20/accessing-operating-system-clipboard-in-chromium-chrome-extensions/ 似乎很有用,但我无法让它覆盖我的系统剪贴板 - 而且我找不到进一步帮助我的教程)。
I wanted to write a simple chrome extension in order to substitute the following sequence of steps which i have to do very often for university:
- make screenshot of something
- edit screenshot in Paint
- save unnamend.png to harddrive
- upload unnamed.png to imageshack.us/pic-upload.de or any
other website
- share link of image with others.
I don't care which image upload service to use, i just want automize this use-case in order to save time (I already red and did a getting-started chrome extension and checked out their API, but that's it, this page: http://farter.users.sourceforge.net/blog/2010/11/20/accessing-operating-system-clipboard-in-chromium-chrome-extensions/ seemed useful, but i couldn't make it overwrite my systems clipboard - moreover i can't find a tutorial which helps me further).
发布评论
评论(1)
为了回答您的问题,我将为您提供一些提示和资源来完成您想要的操作:
1 - 使用 Chrome 扩展 API 的屏幕截图
您可以使用 chrome.tabs.captureVisibleTab 来截屏您所看到的内容。
2 - 使用 HTML5 编辑屏幕截图
好吧,这是一个棘手的问题,为什么你想使用 Paint,而你可以使用 HTML5 或 Web 服务?如果您想使用绘图,那么唯一的方法就是通过 NPAPI (C++ )。确实不鼓励在本机公开某些内容,因为它会给用户带来额外的安全风险。而且提交时需要人工审核,安装时会出现致命警告。
为什么不能使用HTML5 Canvas修改截图?或者甚至,使用 Picnik 在线照片编辑 http://www.picnik.com/
3 - 将图像保存到硬盘驱动器
这是另一个棘手的问题,现在,如果您使用像 Picnick 这样的“服务”,那么您可以使用他们的保存实用程序将其保存到您的硬盘上,否则您可以使用 HTML5 FileWriter API 目前正在开发中。
如果您确实想要使用 MSPaint 路线,那么您需要使用上面提到的 NPAPI。
但是当您使用 HTML5 时,您可以执行以下操作,但它仍处于规范的早期阶段:
4 - 将图像上传到在线图像服务
您可以使用 http://imgurl.com 也可以上传,它有一个简洁的 API 可供您使用。您需要知道的只是普通的旧 JavaScript,只需发送 XHR 请求来请求服务并与其通信。
为此,只需使用他们的 API:
5 - 与其他人共享图像链接。
与上面相同,这只是普通的旧 JavaScript,取决于服务(Facebook、Twitter、Buzz),您使用他们的 API 或其他服务已经为您共享图像。
注意:
我认为执行此扩展的最佳方法是使用 HTML5。您可以使用 XHR 与外部网站通信,使用 Canvas 编辑照片,使用 FileWriter 将其保存到磁盘。
我强烈反对使用 NPAPI 方法进行此类扩展,因为不需要它。另外,如果您使用 NPAPI,则需要使其跨平台并为每个浏览器开发插件。
To answer your questions, I will give you some hints and resources to do what you want:
1 - Screenshot using Chrome Extensions API
You can use chrome.tabs.captureVisibleTab to screenshot what you see.
2 - Edit Screenshot using HTML5
Well, here is a tricky one, why do you want to use Paint while you can use HTML5 or a web service? If you want to use paint, then the only way doing this is natively through NPAPI (C++). Exposing something natively is really discouraged since it poses additional security risks to users. And it requires manual review for submission and a deadly warning when installing.
Why can't you use HTML5 Canvas to modify the screenshot? Or even, use Picnik online photo editing http://www.picnik.com/
3 - Save Image to Hard drive
This is another tricky one, right now, if you use a "service" like Picnick, then you can use their saving utility to save to your harddrive, otherwise you can use HTML5 FileWriter API which is currently being developed.
If you really want to with your MSPaint route, then you would need to use NPAPI as mentioned above.
But when you use HTML5, you can do the following, but it is still early in spec:
4 - Upload image to an Online Image Service
You can use http://imgurl.com to upload too, it has a neat API that you can use. All you need to know is plain old javascript, just send an XHR request to request the service and communicate with it.
To do that, just use their API:
5 - Share link of image with others.
Same as above, this is just plain old javascript, depends on the service (Facebook, Twitter, Buzz), you use their API or another service does that already for you to share the images.
Note:
I would say the best way to do this extension is using HTML5. You can use XHR to communicate to external websites, Canvas to edit the photos, and FileWriter to persist that to disk.
I would highly discourage the NPAPI approach for such extension since it isn't needed. Plus, if you go through NPAPI, you would need to make it cross platform and develop plugins for each browser.