Pure JS now supports arguments

This commit is contained in:
Taevas 2020-12-11 18:44:24 +01:00
parent a3a3f758cf
commit aa0f317d1f
4 changed files with 42 additions and 14 deletions

View file

@ -7,7 +7,7 @@ body {
display: flex; display: flex;
} }
button { input[type="button"] {
padding: 40px; padding: 40px;
margin: 10px; margin: 10px;
font-size: 50px; font-size: 50px;
@ -19,6 +19,14 @@ button {
margin-right: 10%; margin-right: 10%;
} }
form {
display: grid;
}
form * {
margin: 2px 20px;
}
#list { #list {
flex: auto; flex: auto;
width: 600px; width: 600px;

View file

@ -9,7 +9,21 @@
<body> <body>
<div id="rest"> <div id="rest">
<h1>WEBSITE-FINDER</h1> <h1>WEBSITE-FINDER</h1>
<button onclick="findWebsites()">Find websites!</button> <form>
<input type="button" onclick="findWebsites()" value="Find websites!">
<label>Number of URLs to check:</label>
<input type="number" id="times" value="3000">
<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">
<label>Chances out of 100 for a URL to have two domains:</label>
<input type="number" id="second" value="1">
<label>Application protocols (separated with commas):</label>
<input type="text" id="mode" value="http, https">
<label>Minimum URL length (excluding domain and protocol):</label>
<input type="number" id="mini" value="2">
<label>Maximum URL length (excluding domain and protocol):</label>
<input type="number" id="maxi" value="50">
</form>
<p>STATUS: STOPPED</p> <p>STATUS: STOPPED</p>
<p>COUNT:</p> <p>COUNT:</p>
<p>CHECKING:</p> <p>CHECKING:</p>

View file

@ -30,24 +30,30 @@ function findWebsites() {
for (let i = 0; i < url_length; i++) {result += characters.charAt(Math.floor(Math.random() * characters.length))} 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)] 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)]
if (log) console.log(result)
return result return result
} }
const times = 3000 const times = document.getElementById("times").value ? Math.round(Number(document.getElementById("times").value)) : 3000
const domains = ['.co', '.com', '.net', '.edu', '.gov', '.cn', '.org', '.cc', '.us', '.mil', '.ac', '.it', '.de'] const domains = document.getElementById("domains").value ? document.getElementById("domains").value.split(", ") : ['.co', '.com', '.net', '.edu', '.gov', '.cn', '.org', '.cc', '.us', '.mil', '.ac', '.it', '.de']
const mode = ['http', 'https'] const second = document.getElementById("second").value ? Math.round(Number(document.getElementById("second").value)) : 1
const log = false const mode = document.getElementById("mode").value ? document.getElementById("mode").value.split(", ") : ['http', 'https']
const mini = 2 const mini = document.getElementById("mini").value ? Math.round(Number(document.getElementById("mini").value)) : 2
const maxi = 50 const maxi = document.getElementById("maxi").value ? Math.round(Number(document.getElementById("maxi").value)) : 50
const second = 1
const list = document.getElementsByTagName("UL")[0] const list = document.getElementsByTagName("UL")[0]
const status = document.getElementsByTagName("P")[0] const status = document.getElementsByTagName("P")[0]
const count = document.getElementsByTagName("P")[1] const count = document.getElementsByTagName("P")[1]
const url_show = document.getElementsByTagName("P")[2] const url_show = document.getElementsByTagName("P")[2]
console.log('Started at ' + String(new Date().getHours()) + 'h' + String(new Date().getMinutes()) + 'm\n') 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:', mode)
console.log('Minimum length of URLs:', mini)
console.log('Maximum length of URLs:', maxi)
status.innerHTML = "STATUS: ACTIVE" status.innerHTML = "STATUS: ACTIVE"
main_loop() main_loop()

View file

@ -33,9 +33,7 @@ In both cases, I *personally* recommend using the [NoScript extension](https://n
## ARGUMENTS ## ARGUMENTS
JAVASCRIPT CURRENTLY DOESN'T HANDLE ARGUMENTS Unless you're using the Javascript script, if you wish to use arguments, you are required to use the command line in order to launch the script with arguments.
No matter which script, if you wish to use arguments, you are required to use the command line in order to launch the script with arguments.
- "-t" defines the number of URLs the script will go through. - "-t" defines the number of URLs the script will go through.
- "-d" defines all the top-level domains the URLs will use, separated only by a ",". - "-d" defines all the top-level domains the URLs will use, separated only by a ",".
@ -53,6 +51,8 @@ No matter which script, if you wish to use arguments, you are required to use th
* "-MIN" defaults to 2. * "-MIN" defaults to 2.
* "-MAX" defaults to 50. * "-MAX" defaults to 50.
Using arguments with the Javascript script is simple, as you can enter values in labeled fields. Leaving those fields empty will make the script use the default values.
```sh ```sh
# To make the Python script go through 3000 URLs in HTTP with various top-level domains without logging: # To make the Python script go through 3000 URLs in HTTP with various top-level domains without logging:
$ index.py $ index.py