starting a user script from local hard disc possible?

22 views
Skip to first unread message

Ben Stover

unread,
Jan 2, 2010, 11:51:02 AM1/2/10
to Greasemonkey MailingList
Sorry for this newbie question but how do I start a greasemonkey script from my local hard disc?

I wrote the simple script (see bottom of this posting) into a file

D:\tmp\myscript.script

and dragged this file on my Firefox (Greasemonkey addon is installed and enabled).
After dragging the following URL is visible in the browser:

file:///D:/tmp/myscript.script

But after hitting RETURN the script does not run.

Why?

Do all scripts have to be on a server and accessible only through http:// protocol - no file:/// possible?

Ben

// ==UserScript==
// @name Test
// @namespace Foo
// @description Test
// @include *CFIDE/debug/blank.html*
// @version 0.0.1
// ==/UserScript==

var x = document.createElement("<iframe>");
x.src = "http://www.google.com";
document.body.appendChild(x);
var x = document.createElement("<iframe>");
x.src = "http://www.yahoo.com";
document.body.appendChild(x);
var x = document.createElement("<iframe>");
x.src = "http://www.bing.com";
document.body.appendChild(x);


cc

unread,
Jan 2, 2010, 12:57:48 PM1/2/10
to greasemon...@googlegroups.com
At first, I thought your question might be answered by
http://groups.google.com/group/greasemonkey-users/browse_frm/thread/ad67ee03ae92e3f0.
But I guess you're trying to install a script, not run it. Every user
script has to be given a name that ends in .user.js; .script is not an
extension GM recognizes. Whenever you open a .user.js file in Firefox,
Greasemonkey will pop up an installation dialog to confirm you really
want to install the script, so if you don't get that dialog, you know
that GM didn't recognize your file as a user script.

--
cc | pseudonymous |<http://carlclark.mp/>


Matt Sargent

unread,
Jan 2, 2010, 12:58:07 PM1/2/10
to greasemon...@googlegroups.com
This was just answered for me. I'll quote the response I received.

Since a couple of releases there are two new 'hidden' preferences:

greasemonkey.aboutIsGreaseable
greasemonkey.fileIsGreaseable

The default value is "false". If you want Greasemonkey to run on
file:/// urls, you have to set the second one to "true" (in
about:config).

I only run script I've written, but it you run outside script, there is a security issue with changing these settings.
; 
document.body.appendChild(x); 






--

You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemon...@googlegroups.com.
To unsubscribe from this group, send email to greasemonkey-us...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en.





Ben Stover

unread,
Jan 3, 2010, 3:18:12 AM1/3/10
to greasemon...@googlegroups.com, cc, Matt Sargent
Ok, thank you for this first step.

However after setting everything on "true" and rename the extension to ".user.js" I dragged the script file
onto Firefox. Greasemonkey installation dialog pops up and I installed the script successfully. Fine.

But how do I run it (after installation)?

I thought dragging it will run it automatically.

Ben

--Original Message Text---
From: Matt Sargent
Date: Sat, 02 Jan 2010 11:58:07 -0600

esquifit

unread,
Jan 3, 2010, 12:25:45 PM1/3/10
to greasemon...@googlegroups.com
There is a little confusion:

1) In order to *install* a userscript, the file must have the .user.js
extension, regardless of whether the file is a local one or if it is
retrieved via http from some server.

2) In order for the script to *run*, you have to visit some page whose
url matches some of the @include lines in the script header. In your
case, there is just one @include line, namely

@include *CFIDE/debug/blank.html*

This means you have to (install the script and afterwards) visit some
page whose url is something like this:
http://foo.someserver.com/bar/bazCFIDE/debug/blank.html

3) The preferences settings have nothing to do with the above. They
are necessary when you want a script to run upon visiting locally
stored html pages, in other words, when the associated url is of the
form file:///* instead of http://*


I strongly suggest you take a look a the Greasemonkey wiki for further
information about basic features of the extension:

http://wiki.greasespot.net/Main_Page

Reply all
Reply to author
Forward
0 new messages