krb
krb

Reputation: 16345

Getting a greasemonkey script to interact with a running process?

Say I have a local daemon running on my machine, and I want to talk to the daemon from a Greasemonkey script. I know that one of the core concepts of site JavaScript is that it is isolated from everything else, but I was wondering if there was a workaround.

One of the ideas I had was to use a WebSocket to send data to the local daemon but they are only available on Webkit based browsers.

Upvotes: 1

Views: 1622

Answers (2)

Brock Adams
Brock Adams

Reputation: 93613

Three possibilities:

  1. Give the daemon web-server capabilities and then use normal AJAX techniques via GM_xmlhttpRequest() to interact with it.

  2. Instead of a GM script, make a Firefox add-on. Add-ons can interact with the local system in much more dangerous ways than a GM script can.

  3. I do not recommend this last approach, but include it for completeness... It may be possible for the daemon to read and/or write Firefox cookies or localStorage. GM scripts can also, but XSS restrictions apply here (unlike with GM_xmlhttpRequest()).

Upvotes: 4

Jack Murdoch
Jack Murdoch

Reputation: 2894

You could get the daemon to accept HTTP requests, which are done very easily using JavaScript? I think you are going to need to improve the daemon here, rather than the script itself - JavaScript is very secure, and Greasemonkey just takes that a step further.

Upvotes: 1

Related Questions