这是一个小书签。
创建窗口,提取值并将它们写入窗口“log”非常完美。
我想将“log”窗口的内容保存到scrypt.txt,但是父窗口的内容会被保存。我做错了什么?
javascript:
setInterval(logging,60000);
w1 = window.open("https://scrypt.cc/index.php");
log = window.open("");
function logging(){
if(w1.document.body.innerHTML == 'Server is currently busy. Please try again later.'){
w1.location.href = 'https://scrypt.cc/index.php';
console.log("busy");
}else{
console.log("ok");
log.document.body.innerHTML = '';
var re=/var\s*dayprofitperkhs\s*=\s*([0-9\.]+)\s/gi;
var matches=re.exec(w1.document.body.innerHTML);
log.document.write(RegExp.$1 + "<p></p>");
log.document.write(w1.$('#t9_2').val() + "<p></p>");
log.setTimeout(save,1000);
w1.location.href = 'https://scrypt.cc/index.php';
}
}
function save() {
a = log.document.createElement('a');
a.href = log.location.href;
a.download = 'scrypt.txt';
log.document.body.appendChild(a);
a.click();
a.parentNode.removeChild(a);
}
编辑:保存为* .html,另一个a.href工作正常:
a.href = 'data:text/html;base64,' + btoa(log.document.body.outerHTML);
a.download = 'values.html';
答案 0 :(得分:0)
这是一个有效的解决方案:
javascript:
setInterval(logging,60000);
w1 = window.open("https://scrypt.cc/index.php");
log = window.open("");
function logging(){
if(w1.document.body.innerHTML == 'Server is currently busy. Please try again later.'){
w1.location.href = 'https://scrypt.cc/index.php';
console.log("server busy");
}else{
log.document.body.innerHTML = '';
var re=/var\s*dayprofitperkhs\s*=\s*([0-9\.]+)\s/gi;
var matches=re.exec(w1.document.body.innerHTML);
log.document.write("<p>" + RegExp.$1 + "</p>");
log.document.write("<p>" + w1.$('#t9_2').val() + "</p>");
log.setTimeout(save,1000);
w1.location.href = 'https://scrypt.cc/index.php';
}
}
function save() {
console.log("file saved");
a = document.createElement('a');
a.href = 'data:text/html;base64,' + btoa(log.document.body.outerHTML);
a.download = 'values.html';
document.body.appendChild(a);
a.click();
a.parentNode.removeChild(a);
}