开发者

Getting a greasemonkey script to interact with a running process?

开发者 https://www.devze.com 2023-03-17 23:31 出处:网络
Say I have开发者_如何学Python 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 i

Say I have开发者_如何学Python 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.


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()).


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消