Can greasemonkey/javascript read a .txt file?

1,374 views
Skip to first unread message

Reject...@gmail.com

unread,
Sep 13, 2007, 2:07:47 AM9/13/07
to greasemonkey-users
Can greasemonkey/javascript read a .txt file? If so how?

Like I need it to read the first line of a .txt file and store
whatever is on the first line into a greasemonkey variable, which I
can later address.

Dan Phiffer

unread,
Sep 13, 2007, 9:13:01 AM9/13/07
to greasemon...@googlegroups.com

On Sep 13, 2007, at 2:07 AM, Reject...@gmail.com wrote:

>
> Can greasemonkey/javascript read a .txt file? If so how?

That depends, is the text file on a server somewhere? If so, you can
use GM_xmlhttpRequest.


> Like I need it to read the first line of a .txt file and store
> whatever is on the first line into a greasemonkey variable, which I
> can later address.

To store data for later you can use GM_setValue and GM_getValue.

Search for the documentation on those to get started.


>
>
> >

Message has been deleted

Dan Phiffer

unread,
Sep 14, 2007, 1:30:24 AM9/14/07
to greasemon...@googlegroups.com
On Sep 14, 2007, at 12:06 AM, Reject...@gmail.com wrote:

> Actually, its a text file on my own computer and has nothing to do
> with the website. I dunno if theres something that can be done.

I'm pretty sure you don't want Greasemonkey scripts arbitrarily
checking out your local files (plus there are security limitations
preventing you from doing this). You could throw caution to the wind
and set up a local web server exposing the directory where the file
lives. Or write a proper Firefox extension.


>
> On Sep 13, 7:13 am, Dan Phiffer <d...@phiffer.org> wrote:

Reply all
Reply to author
Forward
0 new messages