SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hi, I'm new here.

    Hey, I am new to javascript so I would be asking questions here alot for the next few days. My goal is to create a few greasemonkey scripts so I hope I am in the right place. My first question, can javascript do the same thing you can do in html? I have firebug which I use to edit pages to where I would like to view them, but it seems easy to do that in html. How can I translate that to javascript so I can make those changes permanent?

    BTW I am still doing some tutorials at:
    http://www.webteacher.com/javascript/
    http://www.w3schools.com/js/default.asp
    so I should be able to pick up more information when I am done with those.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,250
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    javascript - html

    Hi chrisdab, welcome to the forums,
    I don't understand exactly what you mean by "do"
    Quote Originally Posted by chrisdab
    can javascript do the same thing you can do in html
    If you are referring to editing js files, you should be able to set your system options to open them in the same text editor that is opening your html files. eg. I use notepad. Javascript is a scripting language and HTML is a mark-up language. Javascript can work with the Document Object Model (DOM) and can access and modify the rendered HTML.
    Quote Originally Posted by chrisdab
    translate that to javascript so I can make those changes permanent
    I wouldn't use javascript to make "permanent" HTML, but it's great for dynamic client-side effects.

  3. #3
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Aye I didnt mean permanent but just as a persistant script for greasemonkey to use on webpages. My goal for my first project is to move some html code around to make it more accessible on a webpage.

    Lets take this code:

    <form action="" method="post">
    <textarea class="form" cols="100" rows="35" name="logedit"/>
    <input type="hidden" value="1" name="poster"/>
    <br/>
    <input type="submit" value="Edit logfile"/>
    </form>

    If I want to move <input type="submit" value="Edit logfile"/> above <textarea class/> I would hope I can do that with a js file.

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,250
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    greasemonkey javascript

    Yes, a GreaseMonkey userscript (javascript) can do that. I'm not sure if it can actually "move" it. More like it "clones" it, removes it from where it was, and inserts the copy in the new place and then renders the page. GM is good for doing that kind of DOM stuff. Have you read and/or worked through any of "Dive into GreaseMonkey" by Mark Pilgrim yet? If there is anything "definitive" GM I'd say that's it. (Fairly) easy to read and it has lot's of examples to experiment with.

  5. #5
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had read through "Dive into GreaseMonkey" but I found it difficult to read. I guess I will run through it again. Thanks.

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,250
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    Dive into GM

    You may have better luck learning if you don't only read it, but fool around a bit with some of the easier examples. Try changing things here and there. When it does something different, try to figure out why what you changed did it. When it breaks, try to figure out why. Of course, the more you know, the easier it will be to be able to "read code", but nothing beats hands on experience.

  7. #7
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks mitt, I will give it another try. Do you think PHP will help me with web activities, like automating functions on browser based games, or is Javascript my best answer?

  8. #8
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,250
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    games

    I don't know enough about games to give a good answer. But PHP is server-side and javascript is client-side, so I guess for a game that involves quick response to action you wouldn't want to have the delays of HTTP requests back and forth to the server bogging things down. But javascript can be seen if the person wanted to "cheat" and mess with the code, so I guess it depends. If someone wants to cheat (eg. slow the alien ships down and make them bigger) and it doesn't affect anyone else, I suppose it doesn't matter.
    The O'Reilly site still has a zip with a whole bunch of GM files that might come in handy for you. http://examples.oreilly.com/greasemonkeyhks/


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •