-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
106 lines (106 loc) · 4.19 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<html>
<head>
<title>Microsoft Rewards Bot</title>
</head>
<body>
<p>Status: <strong id="status">Currently running...</strong></p>
<p>Auto reload page: <strong id="reloadstatus"></strong></p><button id="reload">Toggle</button>
<p>Current search per load: <strong id="searches"></strong></p><button id="change">Change</button> <button id="reset">Reset</button>
<p>Reload delay (ms): <strong id="rd"></strong></p><button id="cdelay">Change</button><br><br>
<button id="dm"><span id="dms"></span> Debug Mode</button>
<script>
window.onload = function(){
function checkBoolean(v){
return ""+v.toLowerCase()==='true';
}
if(!localStorage.getItem("searches"))localStorage.setItem("searches", 1);
if(!localStorage.getItem("autoreload"))localStorage.setItem("autoreload", false);
if(!localStorage.getItem("debug"))localStorage.setItem("debug", false);
if(!localStorage.getItem("rd"))localStorage.setItem("rd", 1000);
window.setInterval(function(){
document.querySelector("#searches").innerText = "" + localStorage.getItem("searches");
document.querySelector("#rd").innerText = "" + localStorage.getItem("rd");
document.querySelector("#reloadstatus").innerText = "" + localStorage.getItem("autoreload");
if(checkBoolean(localStorage.getItem("debug"))){
document.querySelector("#dms").innerText = "Disable";
}else{
document.querySelector("#dms").innerText = "Enable";
}
});
document.querySelector("#reload").onclick = function(){
localStorage.setItem("autoreload", !checkBoolean(localStorage.getItem("autoreload")));
}
document.querySelector("#dm").onclick = function(){
localStorage.setItem("debug", !checkBoolean(localStorage.getItem("debug")));
let dbg = new URL(location.href);
dbg.searchParams.set("debug", localStorage.getItem("debug"));
location.href = dbg;
}
document.querySelector("#change").onclick = function(){
let w = prompt();
if(w<=0||w>100){
alert("Number must between 1 and 100.")
}else{
localStorage.setItem("searches", Number(w));
}
}
document.querySelector("#cdelay").onclick = function(){
let w = prompt();
if(w<=0){
alert("Number must larger than 0.")
}else{
localStorage.setItem("rd", Number(w));
}
}
document.querySelector("#reset").onclick = function(){
localStorage.setItem("searches", 1);
}
let frameReady = 0;
function chargen(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
function createIframe(search){
let chars = chargen(10);
let a = document.createElement("iframe");
let bingurl = new URL("https://www.bing.com/news/search?q=" + Math.random() + chars);
bingurl.searchParams.set("setmkt", "en-us");
bingurl.searchParams.set("setlang", "en");
a.src = bingurl.href;
a.id = chars;
document.body.appendChild(a);
if(!(((new URL(location.href).searchParams.get("debug")+"")).toLowerCase()==='true')){
a.style.display = "none";
a.contentWindow.onload = function(){
window.setTimeout(function(){
a.remove();
}, 2000);
}
frameReady += 1;
}
}
for(let i=0;i<Number(localStorage.getItem("searches"));i++){
createIframe();
}
let isDone = window.setInterval(function(){
if(frameReady>=(Number(localStorage.getItem("searches"))-1)){
window.clearInterval(isDone);
if(checkBoolean(localStorage.getItem("autoreload"))){
document.querySelector("#status").innerText = `Done! Reloading in ${parseFloat(Number(localStorage.getItem("rd"))/1000).toFixed(2)} seconds...`;
window.setTimeout(function(){
location.reload();
}, Number(localStorage.getItem("rd")));
}else{
document.querySelector("#status").innerText = "Done!";
}
}
});
}
</script>
</body>
</html>