1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

ABer

Discussion in 'Code Snippets and Tutorials' started by Wings, May 23, 2011.

  1. Wings

    Wings Level III

    Joined:
    Jun 21, 2009
    Messages:
    573
    Likes Received:
    6
    Location:
    Montreal, Québec
    I made a new thread, but this still kind of relates to the "Making an autobuyer" thread.

    I have a new idea for the autobuyer that I want to make. Since I can't bypass a two word captcha, I guess I could make this autobuyer:

    -Refreshes in the shops with time=const.
    -Finds wanted items and goes to buy page
    -Plays a sound alert (so I hear it and I come to manually enter the captcha)

    Is this more possible? Any idea what is the best language to do that kind of autobuyer?
     
  2. Richy

    Richy Level IV

    Joined:
    Jul 2, 2007
    Messages:
    1,064
    Likes Received:
    58
    this is super easy (relatively)
    may actually be an entry level program
    I think you could do it in almost any language, though I'd suggest GM since that is intended to be used right within the browser, and wouldn't require your program to display the captcha within a separate window dedicated to the program
     
  3. Wings

    Wings Level III

    Joined:
    Jun 21, 2009
    Messages:
    573
    Likes Received:
    6
    Location:
    Montreal, Québec
    Thanks for all these fast answers Richy! :)

    I'll post here again if I need some help!


    Edit1: So far, i'm thinking about doing this for the autobuyer. I might do 3 scripts for my autobuyer (one for refresher, one for going on the buy page and one for a sound alert).

    This would be the script for the sound alert:

    // ==UserScript==
    // @name SoundAlert
    // @namespace What is this supposed to be?
    // @description pops up a window when i'm on a buy page
    // @include Item #1 (that I want to restock) buy page*
    // @include Item #2 (that I want to restock) buy page*
    // @include ...
    // @exclude Shop #1 URL*
    // @exclude Shop #2 URL*
    // @exclude ...
    // ==/UserScript==

    alert('An item restocked');


    Am I on the right track? If i'm right, this script should open a window saying "an item restocked" every time the URL is one of the @include lines. What is @namespace though?
     
  4. Richy

    Richy Level IV

    Joined:
    Jul 2, 2007
    Messages:
    1,064
    Likes Received:
    58
    namespace is kinda a comment line, usually including the author and location the script was downloaded from
    very unimportant if it's just for personal use

    you might find it easier to do the command lines... if, for example, this is Icepets, since the format for the buy page is always icepets.com/blahblahblah/viewshop=(id)&blahblah, and because the asterisk (*) indicates a wildcard, you could either have it look like this:

    // @include http://icepets.com/blahblahblah/viewshop=*&*

    the & is there because, if simply truncating at the 'viewshop,' the alert would sound each time the shop page is refreshed. If you want to use that excluding system you have above, it could work like this:

    // @include http://icepets.com/blahblahblah/viewshop=*
    // @exclude http://icepets.com/blahblahblah/viewshop=(id)

    where you insert one line for each (id). You'd have to analyze the individual site you're making an autobuyer for to fully understand how their buying system works, though! Also, it's common practice to have twice as many @include lines as you would think - one with and one without the www. proceeding the address. While Firefox recognizes addresses without the www., GM would not be able to!
     
  5. Wings

    Wings Level III

    Joined:
    Jun 21, 2009
    Messages:
    573
    Likes Received:
    6
    Location:
    Montreal, Québec
    Okay so I just won't use any namespace XD

    There's one thing I don't understand though. If when you write //, the following things you put are considered as a comment (so they are just ignored probably?), why do we write // ==UserScript== ?

    Is it because we want the userscript to differ from the actual script? This is basically for my own knowledge of course ^.^


    And yeah, I would work with the exclude rules. The way I see it, it's more simple. Yet, it may be because i'm new to this! And yeah I was thinking I needed to know the URL for every item I want to buy and the URL for every shop I want to restock in. I've got some work ahead of me! :p

    Thanks for the double include (www.) tip! And fyi, even though I used to play Icepets, this isn't for Icepets :p. It may turn out that I start playing IP again and that I try to change my script for it to work on IP, but I highly doubt it :\.
     
  6. Richy

    Richy Level IV

    Joined:
    Jul 2, 2007
    Messages:
    1,064
    Likes Received:
    58
    I'm actually not sure on this one :O
    I looked it up, and the ==UserScript== and ==/UserScript== lines, even though they are proceeded by the traditional comment tag (//) signify the start and end of metadata for GM. So, basically, those two lines tell GM where to start and stop looking for information on your script (the information such as name, author, websites, etc).

    Because it's listed with the // ==UserScript== and // ==/UserScript== pair, you should be able to include this segment anywhere. It's kept at the top oftentimes as a common coding courtesy. Also, you usually know the info in the metadata before you know all the code!
     
  7. Wings

    Wings Level III

    Joined:
    Jun 21, 2009
    Messages:
    573
    Likes Received:
    6
    Location:
    Montreal, Québec
    Oh so I could put it up at the end of my script and it wouldn't change anything? So GM already knows on which pages the script executes? (Doesn't GM read from the beginning of your script to the end, sort of like prioritized lists?)
     
  8. Richy

    Richy Level IV

    Joined:
    Jul 2, 2007
    Messages:
    1,064
    Likes Received:
    58
    It does read top to bottom, but I believe it looks for the metadata first
    Check it out here:
    http://diveintogreasemonkey.org/hellowo ... adata.html

    (While describing the UserScript commands):
    "These comments are significant, and must match exactly. Greasemonkey uses them to signal the start and end of your user script metadata. This section may be defined anywhere in your script, but is usually near the top."
     
  9. Wings

    Wings Level III

    Joined:
    Jun 21, 2009
    Messages:
    573
    Likes Received:
    6
    Location:
    Montreal, Québec
    Oh then that's why we can put it anywhere!

    I haven't really looked at diveintogreasemonkey.org a lot though. It says it is out of date... So I still need to find an other guide to helm me with the commands. I've tried wiki.greasespot.net but it's not very "beginner friendly". :\

    Edit: I think I have finished the script for the sound alert. How do I install it? :p

    Edit2: Okay I got it to work! It works very well, except it does not make a sound when the window pops up! :( Any idea of how I can fix this? I'll try to look up on internet and i'll do a Edit3 if I find :p

    Edit3: I think I have found a good guide that will help me learn everything I need to learn. http://commons.oreilly.com/wiki/index.p ... nkey_Hacks
     
  10. Richy

    Richy Level IV

    Joined:
    Jul 2, 2007
    Messages:
    1,064
    Likes Received:
    58
    unfortunately, I'm not good with sound because I'm almost always doing stuff at my computer with sound off
    I can't believe I haven't referred you here yet!

    http://www.w3schools.com/js/default.asp
    w3 schools is a very beginner friendly place to learn javascript!
     
  11. Wings

    Wings Level III

    Joined:
    Jun 21, 2009
    Messages:
    573
    Likes Received:
    6
    Location:
    Montreal, Québec
    Oh no problem :) I'll find out sooner or later!

    Does GM work with javascript?
     
  12. Richy

    Richy Level IV

    Joined:
    Jul 2, 2007
    Messages:
    1,064
    Likes Received:
    58
    well, GM is basically just an easy to use, webpage based version of javascript
     
  13. Wings

    Wings Level III

    Joined:
    Jun 21, 2009
    Messages:
    573
    Likes Received:
    6
    Location:
    Montreal, Québec
    Oh okay. Thanks for the w3schools link!

    It said it was better if I learnt HTML before learning javascript, so I am currently learning HTML. It ain't hard up to now! :O