Results 1 to 7 of 7

Thread: [Script] Wildcard Question

  1. #1

    Joined
    Oct 2017
    Posts
    119
    Thanks
    352
    Thanked
    51/30
    DL/UL
    18/0
    Mentioned
    9 times
    Time Online
    2d 19h N/A
    Avg. Time Online
    1m

    [Script] Wildcard Question

    I've been using the below script for CC, but now that I'm done, I'm thinking of using it for something else. (Anything else, depending on what I want.)

    I was going to ask if any of you thought that it would pick up any nerkmid I found if I simply put the word in the "var items" section, but considering it wouldn't buy something that wasn't capitalized (unless that was when I had the price set wrong and didn't know it), I'm not so sure.

    Ideas?

    Code:
    // ==UserScript==
    // @(you need an account to see links)         Charity Corner - Auto Buy
    // @(you need an account to see links)space    (you need an account to see links)
    // @version      0.2
    // @(you need an account to see links)cription  Auto Buy items that is below certain amount for Charity Corner '18
    // @author       richardscoot
    // @(you need an account to see links)ch        (you need an account to see links)
    // @(you need an account to see links)ch        (you need an account to see links)
    
    // @grant        none
    // ==/UserScript==
    
    // NOTE:
    // 1. SET 'xPrice' to any value that you would love to buy below
    // 2. You may face some error, but that's normal, just click back to check,
    //    if there's anything else there to buy
    // 3. If you want to set to buy things faster, you can change the minTO and maxTO
    //    to your desired value
    // 4. If you want to buy things that is in within the list (Good to buy from a
    //    list of R102-179), you can change "searchWithin" to "true", and change the
    //    "items" list to your own list.
    
    var xPrice = 3000;
    var minTO = 1000;
    var maxTO = 3000;
    var searchWithin = true;
    var showAlert = false;
    
    
    var items = ["Ice Shield", "Poison Snowball Wand", "Yellow Sticky Hand", "Green Sticky Hand", "Tyrannian Skeith Plushie", "Chomby Rocket Belt", "Bruce Fish Slingshot", "GX-4 Oscillabot", "N-4 Info Retrieval Bot", "Ice Dagger"];
    
    var arr = [];
    var arrStr = [];
    var totalItems = 0;
    var totalNP = 0;
    $('a[href*="buy_item.phtml"]').each(function() {
      var str = $(this).attr("href");
      var rex = /old_price=(.*?)\&feat/;
      var matches = str.match(rex);
      if (matches[1] <= xPrice) {
        if (arrStr.indexOf(str) == -1) {
          var stock = {};
          stock.el = $(this);
          stock.el.attr("onclick", "location.href=this.href;return false;");
          stock.np = parseInt(matches[1]);
          arrStr.push(str);
          str = $(this).parent("td").html();
          rex = /<\/b><br>(.*?)\ in stock/;
          matches = str.match(rex);
          stock.total = parseInt(matches[1]);
    
          rex = /<\/a> <br> <b>(.*?)<\/b><br>/;
          matches = str.match(rex);
          var itemName = matches[1];
          if ((searchWithin && items.indexOf(itemName) != -1) || !searchWithin) {
            totalItems = totalItems + stock.total;
            totalNP = totalNP + (stock.total * stock.np);
            arr.push(stock);
          }
        }
      }
    });
    
    
    function buy(idx) {
      var timeout = Math.floor(Math.random() * (maxTO - minTO + 1) + minTO);
      arr[idx].el.click();
      if (arr[idx].total > 1) {
        arr[idx].total--;
      } else {
        idx--;
      }
      if (idx >= 0) {
        setTimeout(function() {
          buy(idx);
        }, timeout);
      } else {
        if (showAlert) {
          alert("You have bought " + totalItems + " items with " + totalNP + " NP.");
        }
      }
    }
    
    if (arr.length > 0) {
      buy(arr.length - 1);
    }
    Last edited by MadameNova; 05-23-2019 at 05:24 PM. Reason: Might help if I bothered to put in the code

  2. #2
    Saiyan Race
    j03's Avatar
    Joined
    Dec 2011
    Posts
    13,722
    Userbars
    166
    Thanks
    5,907
    Thanked
    33,078/6,609
    DL/UL
    23/36
    Mentioned
    3,867 times
    Time Online
    563d 5h 38m
    Avg. Time Online
    3h 13m
    Quote Originally Posted by MadameNova View Post
    I've been using the below script for CC, but now that I'm done, I'm thinking of using it for something else. (Anything else, depending on what I want.)

    I was going to ask if any of you thought that it would pick up any nerkmid I found if I simply put the word in the "var items" section, but considering it wouldn't buy something that wasn't capitalized (unless that was when I had the price set wrong and didn't know it), I'm not so sure.

    Ideas?
    I briefly skimmed over the code... this auto-buys items from the shop wizard? If so, looks like the items variable is feeding the script what items to buy, and I think if you replace one of the items (well, you'd probably want to get rid of the cheap items and put the ones you want) with the nerkmids/whichever items you want to buy, it will do it. You'll have to change some of the limitations, if any, like the max NP to spend and increasing the delay.
    (you need an account to see links)
    (you need an account to see links)(you need an account to see links)

    ------------------------
    [02/24/2013] Stealth CORE is made into the first standalone Neopets auto-player.
    ------------------------


  3. #3

    Joined
    Oct 2017
    Posts
    119
    Thanks
    352
    Thanked
    51/30
    DL/UL
    18/0
    Mentioned
    9 times
    Time Online
    2d 19h N/A
    Avg. Time Online
    1m
    Sort of. You select the shops you want from the wizard, and once you're in the user's shop, it will go searching for whatever you ask it for. (It has cheap stuff listed right now because I just left in the r90+ stuff I was picking up to use with Odd's donator.)

    So you think if I change the cap to 75k (or so) and put in nerkmid, it will work? What kind of timing increase should I consider?

  4. #4
    *squeak*
    Bat's Avatar
    Joined
    Nov 2012
    Posts
    4,036
    Userbars
    153
    Thanks
    2,147
    Thanked
    46,351/3,558
    DL/UL
    34/1
    Mentioned
    1,751 times
    Time Online
    644d 29m
    Avg. Time Online
    3h 42m
    Yes - if you modify the list to search for specific Nerkmids that you want to buy and increase the maximum purchasing limit, the script should be able to buy them for you. I would recommend bumping up your delays to 2-4 seconds for safety's sake, and make sure to take breaks occasionally!

  5. The Following User Says Thank You to Bat For This Useful Post:

    MadameNova (05-24-2019)

  6. #5

    Joined
    Oct 2017
    Posts
    119
    Thanks
    352
    Thanked
    51/30
    DL/UL
    18/0
    Mentioned
    9 times
    Time Online
    2d 19h N/A
    Avg. Time Online
    1m
    Something I forgot to mention yesterday: I have no idea which string controls timing. (But a complete lack of pauses would explain why it occasionally errors out.)

    Thank you for your help.

  7. #6
    *squeak*
    Bat's Avatar
    Joined
    Nov 2012
    Posts
    4,036
    Userbars
    153
    Thanks
    2,147
    Thanked
    46,351/3,558
    DL/UL
    34/1
    Mentioned
    1,751 times
    Time Online
    644d 29m
    Avg. Time Online
    3h 42m
    The variables that control the script's time delays are maxTO and minTO, @(you need an account to see links). Here's an adjusted version of the script. I've modified the delay variables to 2-4 seconds, the maximum price to 75,000 NP and the target items to all of the nerkmids.

    Code:
    // ==UserScript==
    // @(you need an account to see links)         Charity Corner - Auto Buy
    // @(you need an account to see links)space    (you need an account to see links)
    // @version      0.3
    // @(you need an account to see links)cription  Auto Buy items that is below certain amount for Charity Corner '18
    // @author       richardscoot
    // @(you need an account to see links)ch        (you need an account to see links)
    // @(you need an account to see links)ch        (you need an account to see links)
    
    // @grant        none
    // ==/UserScript==
    
    // NOTE:
    // 1. SET 'xPrice' to any value that you would love to buy below
    // 2. You may face some error, but that's normal, just click back to check,
    //    if there's anything else there to buy
    // 3. If you want to set to buy things faster, you can change the minTO and maxTO
    //    to your desired value
    // 4. If you want to buy things that is in within the list (Good to buy from a
    //    list of R102-179), you can change "searchWithin" to "true", and change the
    //    "items" list to your own list.
    
    var xPrice = 75000;
    var minTO = 2000;
    var maxTO = 4000;
    var searchWithin = true;
    var showAlert = false;
    
    var items = ["Aluminium Nerkmid", "Average Nerkmid", "Basic Golden Nerkmid", "Basic Platinum Nerkmid", "Copper Nerkmid", "Golden Nerkmid X", "Golden Nerkmid XX", "Good Nerkmid", "Lesser Nerkmid", "Magical Golden Nerkmid", "Magical Platinum Nerkmid", "Normal Golden Nerkmid", "Normal Platinum Nerkmid", "Platinum Nerkmid X", "Platinum Nerkmid XX", "Super Nerkmid", "Ultimate Nerkmid", "Ultra Golden Nerkmid", "Ultra Nerkmid", "Ultra Platinum Nerkmid"];
    
    var arr = [];
    var arrStr = [];
    var totalItems = 0;
    var totalNP = 0;
    $('a[href*="buy_item.phtml"]').each(function() {
      var str = $(this).attr("href");
      var rex = /old_price=(.*?)\&feat/;
      var matches = str.match(rex);
      if (matches[1] <= xPrice) {
        if (arrStr.indexOf(str) == -1) {
          var stock = {};
          stock.el = $(this);
          stock.el.attr("onclick", "location.href=this.href;return false;");
          stock.np = parseInt(matches[1]);
          arrStr.push(str);
          str = $(this).parent("td").html();
          rex = /<\/b><br>(.*?)\ in stock/;
          matches = str.match(rex);
          stock.total = parseInt(matches[1]);
    
          rex = /<\/a> <br> <b>(.*?)<\/b><br>/;
          matches = str.match(rex);
          var itemName = matches[1];
          if ((searchWithin && items.indexOf(itemName) != -1) || !searchWithin) {
            totalItems = totalItems + stock.total;
            totalNP = totalNP + (stock.total * stock.np);
            arr.push(stock);
          }
        }
      }
    });
    
    
    function buy(idx) {
      var timeout = Math.floor(Math.random() * (maxTO - minTO + 1) + minTO);
      arr[idx].el.click();
      if (arr[idx].total > 1) {
        arr[idx].total--;
      } else {
        idx--;
      }
      if (idx >= 0) {
        setTimeout(function() {
          buy(idx);
        }, timeout);
      } else {
        if (showAlert) {
          alert("You have bought " + totalItems + " items with " + totalNP + " NP.");
        }
      }
    }
    
    if (arr.length > 0) {
      buy(arr.length - 1);
    }

  8. The Following User Says Thank You to Bat For This Useful Post:

    MadameNova (05-24-2019)

  9. #7

    Joined
    Oct 2017
    Posts
    119
    Thanks
    352
    Thanked
    51/30
    DL/UL
    18/0
    Mentioned
    9 times
    Time Online
    2d 19h N/A
    Avg. Time Online
    1m
    Oh my gosh, I thought min/max had to do with price! Wow, thank you for telling me about that...I almost feel embarrassed.

    ETA: I adjusted the original for 2000-4000 and made yours a fresh copy entitled "nerkmid sniffer" so I wouldn't mess up your work.
    Last edited by MadameNova; 05-24-2019 at 09:23 PM.

Posting Permissions

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