How can I persist data and modified outside greasemonkey?

50 views
Skip to first unread message

Stephan Hradek

unread,
Feb 16, 2018, 10:56:31 AM2/16/18
to greasemonkey-users
I've upgraded Greasemonkey and now my usual workflow doesn't work anymore.

Maybe I can get some help here.

I need advice for how to persist data between starts of a greasemonkey script nad additionally be able to read and write the data from "outside".

My workflow was so that I hide certain links on a page when I've already taken care of them.

This "taking care" is done outside the browser with some perl scripts.

When they are done, up to now, read in the gresemonkey user script, added or changed some data and then stored the script.

That way, the next time I run the greasemonkey script, it found the new data and k new what to hide.

Now the userscripts are stored in a database it seems for which I do not know how to access it from outside the browser.

So my questions are:
  • Is there a way I can read or write the scripts from outside the browser?
  • Is there a way the user scripts could access data from the filesystem?
  • Is there any other advice you could give me for how I could solve my requirements?

BTW: Being able to read and write scripts would also help if you want to edit them with a more advanced editor.

Anthony Lieuallen

unread,
Feb 16, 2018, 12:56:03 PM2/16/18
to greasemon...@googlegroups.com
On Fri, Feb 16, 2018 at 10:56 AM Stephan Hradek <stephan...@gmail.com> wrote:
  • Is there a way I can read or write the scripts from outside the browser?
No, and we can't add one.
  • Is there a way the user scripts could access data from the filesystem?
No, and we can't add one.
  • Is there any other advice you could give me for how I could solve my requirements?
Easiest way would be for your custom (perl) script to export an HTTP server, which the script can GM.xhr to, for data passing.

Stephan Hradek

unread,
Feb 16, 2018, 2:03:30 PM2/16/18
to greasemonkey-users


Am Freitag, 16. Februar 2018 18:56:03 UTC+1 schrieb Anthony Lieuallen:
  • Is there any other advice you could give me for how I could solve my requirements?
Easiest way would be for your custom (perl) script to export an HTTP server, which the script can GM.xhr to, for data passing.

That's not as easy as it sounds, compared to what I could do before.

My script would have to start an http server
Would then have to start firefox pointing it to the server
Greasemonkey must the retrieve the data

Possible but a lot of overhead.

:(

Stephan Hradek

unread,
Feb 19, 2018, 6:30:23 AM2/19/18
to greasemonkey-users
Thanks Anthony,

I finally managed to solve my issue.

A Mac usually comes with apache pre-installed, so what I did now is:
  1. My perl script modifies one HTML file (instead of several scripts) to contain the data I want to provide to my scripts.
  2. My perl script then starts Firefox to open this HTML file (through http://localhost, served by the pre-installed apache)
  3. My greasemonkey script, which is now a merge of all my previous scripts, sees that it's running on localhost, pulls out the data from the page and persists it.
  4. My greasemonkey script, when called on one of my target sites, retrieves the persisted data.
Reply all
Reply to author
Forward
0 new messages