基本上,我制作了一个 javascript 来刷新页面,它会找到价格并在商品价格上涨时购买所需的价格。
我让它在没有 iframe 的情况下工作,但我需要在 iframe 中工作,这是我遇到的问题。
如果您访问此页面:[ http://m.roblox.com/items/100933289/privatesales ]
并运行此代码:
alert(document.getElementsByClassName('currency-robux')[0].innerHTML);
您会收到最低价格的提醒。在代码中,这不起作用(因此,我的问题。)
尝试在此页面上运行以下代码以使其正常工作 [ http://www.roblox.com/Junk-Bot-item?id=100933289 ]
var filePath = document.URL;
var itemid = filePath.slice(((filePath.search("="))+1));
var mobileRoot = 'http://m.roblox.com/items/';
var mobileEnd = '/privatesales';
var mobileFilePath = mobileRoot+itemid+mobileEnd;
var iframe2 = '<iframe id="frame" width="100%" height="1" scrolling="yes"></iframe>';
document.write(iframe2);
var iframe = parent.document.getElementById("frame");
iframe.height = 300;
iframe.width = 500;
iframe.src = mobileFilePath;
var price;
var snipe = false;
var lp = Number(prompt("Snipe Price?"));
document.title = "Sniping";
function takeOutCommas(s){
var str = s;
while ((str.indexOf(",")) !== -1){
str = str.replace(",","");
}
return str;
}
function load() {
if (snipe == false) {
tgs = iframe.contentDocument.getElementsByClassName('currency-robux');
price = Number((takeOutCommas(tgs[0].innerHTML)));
alert(price);
}
}
iframe.onload = load;