Finish making the Webpage user-friendly
This commit is contained in:
parent
29fef21cd1
commit
0bf5ad0f6d
3 changed files with 121 additions and 62 deletions
|
@ -1,26 +1,36 @@
|
|||
$(function() {
|
||||
$("#btn").click(findWebsites)
|
||||
})
|
||||
|
||||
function findWebsites() {
|
||||
|
||||
async function main_loop() {
|
||||
for (let i = 0; i < times; i++) {
|
||||
count.innerHTML = `COUNT: ${i+1}/${times}`
|
||||
const url = url_generator()
|
||||
url_show.innerHTML = `CHECKING: ${url}`
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {mode: "no-cors"})
|
||||
let li = document.createElement("LI")
|
||||
let a = document.createElement("A")
|
||||
a.innerHTML = url
|
||||
a.href = url
|
||||
li.appendChild(a)
|
||||
list.appendChild(li)
|
||||
audio.play()
|
||||
}
|
||||
catch (e) {} // No server for this URL
|
||||
}
|
||||
$("#actual_list").html("")
|
||||
$("#log_start").html(`Started at ${new Date().toLocaleTimeString()}`)
|
||||
$("#log_length").html(`Length of domains is ≥ ${min} and ≤ ${max}`)
|
||||
$("#log_protocols").html(`Protocols are ${String(protocols).replace(/,/g, ", ")}`)
|
||||
$("#log_tlds").html(`TLDs are ${String(domains.map((d) => "."+d)).replace(/,/g, ", ")}`)
|
||||
$("#status").slideDown()
|
||||
$("#finder").slideUp()
|
||||
$("#progress").addClass("in_progress")
|
||||
|
||||
console.log('\nFinished at ' + String(new Date().getHours()) + 'h' + String(new Date().getMinutes()) + 'm')
|
||||
status.innerHTML = "STATUS: STOPPED"
|
||||
for (let i = 0; i < times; i++) {
|
||||
const url = url_generator()
|
||||
$("#log_count").html(`${i+1}/${times}`)
|
||||
$("#log_checking").html(`${url}`)
|
||||
|
||||
const controller = new AbortController()
|
||||
const signal = controller.signal
|
||||
setTimeout(() => controller.abort(), 8000)
|
||||
await fetch(url, {mode: "no-cors", signal}).then((_response) => {
|
||||
let html = `<li>${new Date().toLocaleTimeString()}: <a href=${url} target="_blank" rel="noopener noreferrer">${url}</a></li>`
|
||||
$(html).hide().appendTo($("#actual_list")).slideDown()
|
||||
audio.play()
|
||||
}).catch((e) => {})
|
||||
}
|
||||
$("#finder").slideDown()
|
||||
$("#progress").removeClass("in_progress")
|
||||
|
||||
console.log("\nFinished at " + String(new Date().toLocaleTimeString()))
|
||||
document.getElementById("btn").disabled = false
|
||||
}
|
||||
|
||||
|
@ -30,35 +40,27 @@ function findWebsites() {
|
|||
const characters = "abcdefghijklmnopqrstuvwxyz0123456789"
|
||||
for (let i = 0; i < url_length; i++) {result += characters.charAt(Math.floor(Math.random() * characters.length))}
|
||||
result += `.${domains[Math.floor(Math.random() * domains.length)]}`
|
||||
if (Math.floor(Math.random() * (100 - 1) + 1) <= second) result += domains[Math.floor(Math.random() * domains.length)]
|
||||
if (Math.floor(Math.random() * (100 - 1) + 1) <= second) result += `.${domains[Math.floor(Math.random() * domains.length)]}`
|
||||
return result
|
||||
}
|
||||
|
||||
const audio = new Audio("found.mp3")
|
||||
|
||||
const times = document.getElementById("times").value ? Math.round(Number(document.getElementById("times").value)) : 2000
|
||||
const protocols = document.getElementById("protocols").value ? document.getElementById("protocols").value.split(", ") : ['https']
|
||||
const domains = document.getElementById("domains").value ? document.getElementById("domains").value.split(", ") : ["com", "org", "net", "tk", "cn", "de", "ru", "uk", "nl", "ca", "au", "in", "ir", "tv", "live", "gov", "edu"]
|
||||
const second = document.getElementById("second").value ? Math.round(Number(document.getElementById("second").value)) : 0
|
||||
const min = document.getElementById("min").value ? Math.round(Number(document.getElementById("min").value)) : 2
|
||||
const max = document.getElementById("max").value ? Math.round(Number(document.getElementById("max").value)) : 15
|
||||
const times = $("#times").val() ? Math.round(Number($("#times").val())) : 2000
|
||||
const protocols = $("#protocols").val() ? $("#protocols").val().split(", ") : ["https"]
|
||||
const domains = $("#domains").val() ? $("#domains").val().split(", ") : ["com", "org", "net", "tk", "cn", "de", "ru", "uk", "nl", "ca", "au", "in", "ir", "tv", "live", "gov", "edu"]
|
||||
const second = $("#second").val() ? Math.round(Number($("#second").val())) : 0
|
||||
const min = $("#min").val() ? Math.round(Number($("#min").val())) : 2
|
||||
const max = $("#max").val() ? Math.round(Number($("#max").val())) : 15
|
||||
|
||||
const list = document.getElementById("list").getElementsByTagName("UL")[0]
|
||||
const status = document.getElementsByTagName("P")[0]
|
||||
const count = document.getElementsByTagName("P")[1]
|
||||
const url_show = document.getElementsByTagName("P")[2]
|
||||
console.log("Started at", String(new Date().toLocaleTimeString()))
|
||||
console.log("Number of URLs being checked:", times)
|
||||
console.log("TLDs used in URLs:", domains)
|
||||
console.log("How many URLs out of 100 will feature two domains:", second)
|
||||
console.log("Application protocols used by URLs:", protocols)
|
||||
console.log("Minimum length of URLs:", min)
|
||||
console.log("Maximum length of URLs:", max)
|
||||
|
||||
console.log('Started at', String(new Date().getHours()) + 'h' + String(new Date().getMinutes()) + 'm\n')
|
||||
console.log('Number of URLs being checked:', times)
|
||||
console.log('Domains used in URLs:', domains)
|
||||
console.log('How many URLs out of 100 will feature two domains:', second)
|
||||
console.log('Application protocols used by URLs:', protocols)
|
||||
console.log('Minimum length of URLs:', min)
|
||||
console.log('Maximum length of URLs:', max)
|
||||
|
||||
|
||||
status.innerHTML = "STATUS: ACTIVE"
|
||||
document.getElementById("btn").disabled = true
|
||||
|
||||
main_loop()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue