1

I have a webpage on which I'm doing tons of cool stuff using greasemonkey. I'm actually pretty terrible at greasemonkey/javascript but I'm learning quick. Every once in a while I get a really terrible CAPTCHA validation which I want to automate. I have a command-line utility that can do this with local and remote files, but not with the file in question because It's behind a session..

tim@g2sv ocr-thingy my-image.png
135189

Works like a charm. I'm looking for a way to pass the image from the website (running the script) to the utility. I don't care how complicated it has to be, but at the moment I'm clueless. I've been thinking about providing the utility as some type of REST-like API for greasemonkey to interface with but I don't know how to supply an image to an API other than by passing the URL which doesn't work (as stated before). Greasemonkey (luckly) doesn't allow you to download a file an run software on my PC so the most straightforward option is out.

I'm open to all suggestions it's a fun side-project for me so the crazier the better ;) I would prefer an option that silently runs in the background (doesn't take or require focus like mouse and keyboard controlling software, java robot).

Maybe you're interested to know I'm not trying to brake any laws or anything, the owner of the website knows I'm doing this and was interested to see if I was able to do it!

TFennis
  • 1,393
  • 1
  • 14
  • 23

1 Answers1

3

"I don't care how complicated it has to be, but at the moment I'm clueless."

Well, it's possible, but it is an "involved" process. Here's the high level steps:

Approach 1:

  • Forget about Greasemonkey; write a Firefox add-on. Add-ons can interact with the file system and probably can get the image data without having to use Flash or Canvas.

Approach 2:

  • Use Greasemonkey and JS to send the image data to your server (using GM_xmlhttpRequest()). This is not simple, search around for how to do that.

  • Your server can be your own local machine running something like XAMPP or any one of the free web-application servers.

  • Your server uses PHP (or Coldfusion, or C#, or Python, etc.) to run your OCR program and do whatever you want with the results, including AJAXing them back to the GM script.

Community
  • 1
  • 1
Brock Adams
  • 90,639
  • 22
  • 233
  • 295
  • Thanks for your help so far<3. I've thought about the second Approach myself. I know how to use GM_xmlhttpRequest, XAMPP and PHP. But how do "send the image" with the httprequest. If I simply pass the URI to the image to the "API" I won't be able to retrieve the image because the http server doesn't have a session to the website. – TFennis Jan 02 '12 at 22:57
  • 2
    There are questions here on SO that discuss that. I don't have them bookmarked, but start with ["Get image data in Javascript"](http://stackoverflow.com/q/934012/331508). – Brock Adams Jan 02 '12 at 23:32
  • Thanks I think I know enough to continue! – TFennis Jan 03 '12 at 09:29