dynamic loading local js scripts

217 views
Skip to first unread message

Wuka

unread,
Jun 21, 2012, 11:03:25 AM6/21/12
to greasemon...@googlegroups.com
hi i am new so dont mind me if my question is simply stupid :)

so i dont really know if it is even possible to do what i want to do :)
and what i want is to dynamicly load my local scripts from Main.user.js script

i know i can load from internet like this
var script = document.createElement('script');
script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js';
document.getElementsByTagName('head')[0].appendChild(script);

and what i want is
var script = document.createElement('script'); script.src = 'c:/myscript/dependency1.js'; document.getElementsByTagName('head')[0].appendChild(script);

is there a library for local i/o ?

you may ask, wtf? why would you like to do that ?
and my answear is: i have strong C# background
and i would like to see some feature like

include somescript.js

for my dependencies
ofc i can set many *.user.js files in greasy monkey, but i would like to do that dynamicly





Anthony Lieuallen

unread,
Jun 21, 2012, 12:38:41 PM6/21/12
to greasemon...@googlegroups.com
On Thu, Jun 21, 2012 at 11:03 AM, Wuka <wojciec...@gmail.com> wrote:
and what i want is to dynamicly load my local scripts from Main.user.js script

You can't do this.  You can use @require to pull in separate files at install time.  They can be relative paths, so local *if you're installing the script from a local file*.  But you can't read nor run files on the local disk at run time.  If you can it's a security bug that we'll close as soon as we're aware of it.

mike cupcake

unread,
Jun 21, 2012, 7:38:35 PM6/21/12
to greasemon...@googlegroups.com

Am I right in thinking you could run a local webserver and reference the files via http://127.0.0.1/...   ?
Reply all
Reply to author
Forward
0 new messages