GM Question (adding buttons and purposes)

Discussion in 'Code Snippets and Tutorials' started by Fexxel, Apr 20, 2009.

  1. Fexxel

    Fexxel Level IV

    Joined:
    Jan 28, 2009
    Messages:
    959
    Likes Received:
    26
    Is Grease Monkey only for changing webpages and not making your browser do something?
    And if I wanted to make a sponsor doer:
    Could I add a button to neopets.com's side bar to visit a bunch of links? If so, how?
     
  2. Brian

    Brian Level I

    Joined:
    Apr 14, 2009
    Messages:
    92
    Likes Received:
    8
    Location:
    Daytona Beach, FL
    what you would do is write a script to make it go to all the links that you want it to go to. then have it be activated when you go to a certain page.
     
    Zer0 likes this.
  3. Heya_old

    Heya_old Level IV

    Joined:
    Mar 31, 2008
    Messages:
    928
    Likes Received:
    46
    its not as simple as it might look. You need to understand HTML and how everything in HTML functions. You'll use DOM to minipulate the pages. You need to learn javascript, and how it works with the client. Big mistake that i made and see is that javascript is client-side, not server-side, so there no way to contact the server with it unless you use a backdoor trick.

    it you want to use GUI, you need to learn about who forms work, and different types of requests and what not. Its not like vb.net where you can just jump right into it...
     
  4. Brian

    Brian Level I

    Joined:
    Apr 14, 2009
    Messages:
    92
    Likes Received:
    8
    Location:
    Daytona Beach, FL
    It's a scripting language it is not that difficult but there is a learning curve to it!
     
  5. Heya_old

    Heya_old Level IV

    Joined:
    Mar 31, 2008
    Messages:
    928
    Likes Received:
    46
    but to use javascript in the way to write gm scripts is harder then regular javascript on web pages. You have to find different ways to get stuff then other programming languages.
     
  6. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    Well, not really. Javascript's DOM Functions are 'more regular' than the methods we use in Vb to find data in a page. Javascript uses an XML structure, which is really flexible and easy-to-use. There are many ways to get specific data from a page, as you can take into consideration more than just one object.

    And, to stay on topic, I'll also answer Fexxel's question. JavaScript was originally made to modify a page's look, without interfering with the server-part of the page. But as JavaScript was further developed, it got some functions implemented to make it interact with the server: this technology is called AJAX. However, making EVERY site accessible from any page would have been a security risk, and that's why common browsers raise a security exception when a site attempts to do so. Greasemonkey got a step ahead, though. It has a built-in function which allows cross-site requests, making it possible to do almost anything you want to do on the page. Just take a look at Javascript's XMLHttpRequest object and at GM's GM_xmlHttpRequest function. ;)