-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathscript.js
84 lines (80 loc) · 2.34 KB
/
script.js
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
var config = {
// Easily just add extensions bellow and the program will go through them
"Documents": [
"pdf",
"doc",
"docx",
"csv",
"xls",
"xlsx",
"txt",
"rtf",
"odt",
"ppt",
"pptx",
"pptm",
"xml",
"klm"
],
"Databases": [
"php",
"sql",
"sqlite",
"pdb",
"idb",
"cdb",
"sis",
"odb"
],
"Software": [
"env",
"cfg",
"conf",
"config",
"cfm",
"log",
"inf"
]
};
//--------------------------------------------------------------
//get checkbox elements
var checkDocuments = document.getElementById("searchDocuments");
var checkDatabases = document.getElementById("searchDatabases");
var checkSoftware = document.getElementById("searchSoftware");
var counter = 0; //global counter for blocked popups
//get text placeholders
var site = document.getElementById('site');
var keyword = document.getElementById('keyword');
//--------------------------------------------------------------
function search() {
counter = 0; //reset counter on every click
console.log(counter);
//Checking if none of the checkboxes are checked and alerts the user
if (!checkDocuments.checked && !checkDatabases.checked && !checkSoftware.checked) {
alert("You have to check one option");
}
//Depending on the checkbox checked, run that query with array provided
if (checkDocuments.checked) {
searchQuery(config.Documents);
}
if (checkDatabases.checked) {
searchQuery(config.Databases);
}
if (checkSoftware.checked) {
searchQuery(config.Software);
}
// Check if it detected blocked popups
if (counter > 0) {
alert(`Our checker says ${counter} popups might have been blocked, please allow popups and try again!`);
}
}
function searchQuery(array) {
array.forEach(extension => {
isBlocked(window.open(`http://google.com/search?q=site%3A${site.value}+filetype%3A${extension}+%22${keyword.value}%22`, "_blank"));
});
}
function isBlocked(popupWindow){
if (!popupWindow || popupWindow.closed || typeof popupWindow.closed == 'undefined') {
counter += 1;
}
}