my goal is to create a sort of “Javascript library,” if you could call it that. I’m intending to use it to just manipulate pages as I browse the web, dynamically loading it as a greasemonkey script. The idea is to have “win” get mapped to window, “doc” -> document, “win.loc” -> win.location, and a few other convenience mappings, but you get the idea. Can you just give me a few examples for me to pick up the syntax from, and I’ll extrapolate the rest? Thanks so much.
my goal is to create a sort of Javascript library, if you could call
Share
Just assign variables like so:
You can’t assign
win.locwithout modifying thewindowobject in this case though. Also, the window object is special because after assigningwin, you’ll be able to get it withwin.winorwin.win.winand so on (windowis the global object.)In any case, you can still assign
locto thewindowobject:Now that is how to do what you’re asking for. Most likely you shouldn’t do this. Normally, frameworks are defined to use up only one global variable, with a suitable name:
All this is pretty complex stuff if you’re not familiar with JavaScript though, so it’s not a good project to start with if you’re new to JavaScript.