Added pure JS for webpage (Javascript folder) & README.md update

This commit is contained in:
Taevas 2020-12-10 03:24:05 +01:00
parent 451cc10561
commit fd5b2a7381
4 changed files with 121 additions and 3 deletions

36
Javascript/index.css Normal file
View file

@ -0,0 +1,36 @@
* {
text-align: center;
}
button {
padding: 40px;
margin: 50px;
font-size: 50px;
}
#list {
height: 500px;
padding: 20px;
margin: 10px 100px;
overflow-x: hidden;
overflow-y: auto;
background-color: black;
}
ul {
padding: 0px;
}
li {
list-style: none;
font-size: 20px;
margin: 10px;
}
a:link {
color: white;
}
a:visited {
color: gray;
}

20
Javascript/index.html Normal file
View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<title>Website-Finder</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="./index.css">
<script type="text/javascript" src="./index.js"></script>
</head>
<body>
<button onclick="findWebsites()">Find websites!</button>
<p>STATUS: STOPPED</p>
<p>COUNT:</p>
<p>CHECKING:</p>
<div id="list">
<ul>
</ul>
</div>
</body>
</html>

55
Javascript/index.js Normal file
View file

@ -0,0 +1,55 @@
function findWebsites() {
async function main_loop() {
for (let i = 0; i < times; i++) {
count.innerHTML = `COUNT: ${i+1}/${times}`
const url = await 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)
}
catch (e) {
let a = 0
}
}
console.log('\nFinished at ' + String(new Date().getHours()) + 'h' + String(new Date().getMinutes()) + 'm')
status.innerHTML = "STATUS: STOPPED"
}
function url_generator() {
let result = mode[Math.round(Math.random() * (mode.length - 1))] + "://"
const characters = "abcdefghijklmnopqrstuvwxyz0123456789"
const url_length = Math.floor(Math.random() * (maxi - mini) + mini)
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 (log) console.log(result)
return result
}
const times = 3000
const domains = ['.co', '.com', '.net', '.edu', '.gov', '.cn', '.org', '.cc', '.us', '.mil', '.ac', '.it', '.de']
const mode = ['http', 'https']
const log = false
const mini = 2
const maxi = 50
const second = 1
const list = document.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().getHours()) + 'h' + String(new Date().getMinutes()) + 'm\n')
status.innerHTML = "STATUS: ACTIVE"
main_loop()
}

View file

@ -1,6 +1,8 @@
# Website-Finder
Website-Finder is a collection of light scripts written in various programming languages without the need for external libraries that finds websites of all sorts for you and make reports of that in the form of automatically generated json files.
Website-Finder is a collection of light scripts written in various programming languages without the need for external libraries that finds websites of all sorts for you and make reports of that either in the form of automatically generated json files or in the form of a webpage.
Keep in mind that this software will find ANY website that exists, no matter how morally wrong it may be. It may also (on purpose) find websites which are hosted by a server that simply doesn't reply to requests.
## REQUIREMENTS
@ -9,6 +11,7 @@ Each script has its own requirements.
* index.py, the Python script, requires [Python 3](https://www.python.org/downloads/)
* index.js, the Node.js script, requires [Node.js](https://nodejs.org/en/download/)
* index.rb, the Ruby script, requires [Ruby](https://rubyinstaller.org/downloads/)
* index.html, the Javascript script within a HTML webpage, only requires a web browser
## HOW TO RUN
@ -21,10 +24,14 @@ $ cd Website-Finder/Node.js
$ node index.js
```
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.
For the Javascript script, you only need to run the HTML file into your web browser, by either double-clicking it or by dragging the file into it.
## ARGUMENTS
JAVASCRIPT CURRENTLY DOESN'T HANDLE 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.
- "-d" defines all the top-level domains the URLs will use, separated only by a ",".
- "-m" defines the application protocol used. Multiple protocols can be defined by separating them with a ",".
@ -57,5 +64,5 @@ $ node index.js -m https -l
Q: Is there a script that is better than the other?
A: As far as I am aware, nope! However, the reports are generated differently depending of the script and some websites send different codes depending of the script.
Q: Why does the "-m" argument defaults to "http" rather than "https"?
Q: Why does the "-m" argument default to "http" rather than "https"?
A: Requests in "http" receive more status codes than error codes compared to "https". I suspect it's because some websites don't support "https" very well, even in the current year.