Pure JS now has its button disabled during search

This commit is contained in:
Taevas 2021-03-06 17:12:51 +01:00
parent 47df44ca38
commit 41adf539c9
2 changed files with 6 additions and 5 deletions

View file

@ -10,14 +10,14 @@
<div id="rest"> <div id="rest">
<h1>WEBSITE-FINDER</h1> <h1>WEBSITE-FINDER</h1>
<form> <form>
<input type="button" onclick="findWebsites()" value="Find websites!"> <input type="button" id="btn" onclick="findWebsites()" value="Find websites!">
<label>Number of URLs to check:</label> <label>Number of URLs to check:</label>
<input type="number" id="times" value="3000"> <input type="number" id="times" value="3000">
<label>Domains to check (separated with commas):</label> <label>Domains to check (separated with commas):</label>
<input type="text" id="domains" value=".co, .com, .net, .edu, .gov, .cn, .org, .cc, .us, .mil, .ac, .it, .de"> <input type="text" id="domains" value=".co, .com, .net, .edu, .gov, .cn, .org, .cc, .us, .mil, .ac, .it, .de">
<label>Chances out of 100 for a URL to have two domains:</label> <label>Chances out of 100 for a URL to have two domains:</label>
<input type="number" id="second" value="1"> <input type="number" id="second" value="1">
<label>Application protocols (separated with commas):</label> <label>Application protocols (separated with ", "):</label>
Please note that http requests (not https) will not work if the file is not run locally, <b>putting http in that field is useless if you're using GitHub Pages</b> Please note that http requests (not https) will not work if the file is not run locally, <b>putting http in that field is useless if you're using GitHub Pages</b>
<input type="text" id="mode" value="https"> <input type="text" id="mode" value="https">
<label>Minimum URL length (excluding domain and protocol):</label> <label>Minimum URL length (excluding domain and protocol):</label>

View file

@ -5,6 +5,7 @@ function findWebsites() {
count.innerHTML = `COUNT: ${i+1}/${times}` count.innerHTML = `COUNT: ${i+1}/${times}`
const url = await url_generator() const url = await url_generator()
url_show.innerHTML = `CHECKING: ${url}` url_show.innerHTML = `CHECKING: ${url}`
try { try {
const response = await fetch(url, {mode: "no-cors"}) const response = await fetch(url, {mode: "no-cors"})
let li = document.createElement("LI") let li = document.createElement("LI")
@ -14,13 +15,12 @@ function findWebsites() {
li.appendChild(a) li.appendChild(a)
list.appendChild(li) list.appendChild(li)
} }
catch (e) { catch (e) {} // No server for this URL
let a = 0
}
} }
console.log('\nFinished at ' + String(new Date().getHours()) + 'h' + String(new Date().getMinutes()) + 'm') console.log('\nFinished at ' + String(new Date().getHours()) + 'h' + String(new Date().getMinutes()) + 'm')
status.innerHTML = "STATUS: STOPPED" status.innerHTML = "STATUS: STOPPED"
document.getElementById("btn").disabled = false
} }
function url_generator() { function url_generator() {
@ -55,6 +55,7 @@ function findWebsites() {
status.innerHTML = "STATUS: ACTIVE" status.innerHTML = "STATUS: ACTIVE"
document.getElementById("btn").disabled = true
main_loop() main_loop()