I think it is. Note that you will not be able to modify and re-save the
values, which might be what you want. But read-only would work. You will
probably have to mess with it some to get it all to work. I did a quick
semi-proof of concept just to make sure it will work, but just barely
scraped the surface. I think I could actually get it to work if I kept
at it, but I don't want to spend that much time on it.
If you have a JSON object data structure in the text file, you can
easily set the values using eval(). Or, to be safe, get one of the JSON
libraries and "do it right". ('safer' than eval) Or make up your own
storage data structure and parse it yourself. Whatever. There are a lot
of ways to do it.
If you do something like: (this will cause a "flash" in the browser if
you save and reload the file, which would also have to be checked for so
it doesn't execute in an infinite loop, so you will have to mess with it
somehow to make it all work better -- maybe create an inline frame to do
it?)
window.location = "file:///C:/temp/textvars.txt";
var sJSON = window.document.body.innerHTML; // you will have to remove
leading and trailing <pre> tags
var oJSON = eval (sJSON);
Ben Stover wrote:
> Is it possible to let greasemonkey read some user parameters from a text file
> on the local hard disc?
>
> If yes: Could you give a sample code to read e.g. the first and second line
> of a text file from
>
> D:\myproj\greaseparm.txt
>
> and assign them to the greasemonkey script variables
>
> var first = ....
> and
> var second = ....
>
> Thank you
> Ben
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"greasemonkey-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---