MadameNova
05-23-2019, 05:23 PM
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?
// ==UserScript==
// name Charity Corner - Auto Buy
// namespace [Only registered and activated users can see links]
[Only registered and activated users can see links]
// Description Auto Buy items that is below certain amount for Charity Corner '18
[Only registered and activated users can see links]
// Match [Only registered and activated users can see links]*
// Match [Only registered and activated users can see links]*
[Only registered and activated users can see links]
// ==/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);
}
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?
// ==UserScript==
// name Charity Corner - Auto Buy
// namespace [Only registered and activated users can see links]
[Only registered and activated users can see links]
// Description Auto Buy items that is below certain amount for Charity Corner '18
[Only registered and activated users can see links]
// Match [Only registered and activated users can see links]*
// Match [Only registered and activated users can see links]*
[Only registered and activated users can see links]
// ==/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);
}