PageSourceSearch

https://www.ckauto.cz/media/admin/js/protection.js

js ckauto.cz collected 2026-10-08 05:41:36 UTC 2,319 bytes, 76 lines download raw bytes

1var FormProtection = function () {
2    this.elem = "div[data-fp]";
3    this.elems = {};
4
5    this.after = function (form) {
6        form.submit();
7    };
8
9    this.init = function(after,elem) {
10        if(typeof after === "function") {
11            this.after = after;
12        }
13
14        if(typeof elem !== "undefined" && elem !== ".fp") {
15            this.elem = elem;
16        }
17
18        this.elems = document.querySelectorAll(this.elem);
19        //console.log(this.elems);
20        for (var i=0; i<this.elems.length; i++) {
21            //console.log(this.elems[i]);
22            this.elems[i].style = "display:none;";
23            //this.elems[i].querySelector(".src_wbp");
24            this.elems[i].appendChild(this.createInput());
25
26            this.addWatch(this.elems[i].querySelector(".fp"));
27        }
28    };
29    this.createInput = function() {
30        var inp = document.createElement("INPUT");
31        inp.type = "text";
32        inp.className = "fp";
33        inp.value = "";
34        inp.name = "fp-inp"
35        return inp;
36    };
37
38    this.addWatch = function (elem) {
39        var prot = this;
40        elem.form.addEventListener("submit", function (e) {
41            e.preventDefault();
42            if(e.target.querySelector(".fp").value === "") {
43                prot.beforeSend(e.target,prot.after);
44            } else {
45                console.log("Ungenerated");
46            }
47        });
48    };
49
50    this.beforeSend = function(form,onSuccess) {
51        this.ajaxRequest("GET","/external/form_token",function(data,form) {
52            if(typeof data == "string") {
53                form.querySelector(".fp").value = JSON.parse(data);
54            }
55            //console.log(JSON.parse(data));
56            onSuccess(form);
57        },form);
58        //console.log("activate protection: ",form);
59        //onSuccess(form);
60    };
61
62    this.ajaxRequest = function(method,url,callback,form) {
63        var xhr = new XMLHttpRequest();
64        xhr.open(method, url,true);
65        xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
66        xhr.onload = function() {
67            if (xhr.status === 200) {
68                callback(xhr.response,form);
69            }
70            else {
71                alert('Request failed.  Returned status of ' + xhr.status);
72            }
73        };
74        xhr.send("");
75    }
76};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.