PageSourceSearch

https://klvadm.ru/bitrix/js/intervolga.privacy/xhrUtils.js?17168962842843

js klvadm.ru collected 2026-10-02 10:08:35 UTC 2,843 bytes, 98 lines download raw bytes

1;(function () {
2    'use strict';
3
4    var xhrUtils = {};
5
6    var COMPLETED_READY_STATE = 4;
7    var RealXHRSend = XMLHttpRequest.prototype.send;
8    var requestCallbacks = [];
9    var responseCallbacks = [];
10
11    var wired = false;
12
13    xhrUtils.isWired = function() {
14        return wired;
15    };
16
17    /**
18     * Wires
19     */
20    xhrUtils.wire = function() {
21        if ( wired ) throw new Error("Already wired");
22
23        // Override send method of all XHR requests
24        XMLHttpRequest.prototype.send = function() {
25
26            // Fire request callbacks before sending the request
27            fireCallbacks(requestCallbacks, this);
28
29            // Wire response callbacks
30            if( this.addEventListener ) {
31                var self = this;
32                this.addEventListener("readystatechange", function() {
33                    fireResponseCallbacksIfCompleted(self);
34                }, false);
35            }
36            else {
37                proxifyOnReadyStateChange(this);
38            }
39
40            RealXHRSend.apply(this, arguments);
41        };
42        wired = true;
43    };
44
45    xhrUtils.unwire = function() {
46        if ( !wired ) throw new Error("Ajax interceptor not currently wired");
47        XMLHttpRequest.prototype.send = RealXHRSend;
48        wired = false;
49    };
50
51    xhrUtils.addRequestCallback = function(callback) {
52        requestCallbacks.push(callback);
53    };
54    xhrUtils.removeRequestCallback = function(callback) {
55        arrayRemove(requestCallbacks,callback);
56    };
57
58    xhrUtils.addResponseCallback = function(callback) {
59        responseCallbacks.push(callback);
60    };
61    xhrUtils.removeResponseCallback = function(callback) {
62        arrayRemove(responseCallbacks,callback);
63    };
64
65    function fireResponseCallbacksIfCompleted(xhr) {
66        if( xhr.readyState === COMPLETED_READY_STATE ) {
67            fireCallbacks(responseCallbacks,xhr);
68        }
69    }
70
71    function proxifyOnReadyStateChange(xhr) {
72        var realOnReadyStateChange = xhr.onreadystatechange;
73        if ( realOnReadyStateChange ) {
74            xhr.onreadystatechange = function() {
75                fireResponseCallbacksIfCompleted(xhr);
76                realOnReadyStateChange();
77            };
78        }
79    }
80
81    function arrayRemove(array,item) {
82        var index = array.indexOf(item);
83        if (index > -1) {
84            array.splice(index, 1);
85        } else {
86            throw new Error("Could not remove " + item + " from array");
87        }
88    }
89
90    function fireCallbacks(callbacks,xhr) {
91        for( var i = 0; i < callbacks.length; i++ ) {
92            callbacks[i](xhr);
93        }
94    }
95
96    window.PrivacyPolicyIV = window.PrivacyPolicyIV || {};
97    window.PrivacyPolicyIV.xhrUtils = xhrUtils;
98})();

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.