PageSourceSearch

https://www.starwoodhotels.com/modules/contrib/cleantalk/js/apbct-public.js?v=2.x

js starwoodhotels.com collected 2026-09-24 08:29:34 UTC 9,126 bytes, 346 lines download raw bytes

1var d = new Date(),
2    ctTimeMs = new Date().getTime(),
3    ctMouseEventTimerFlag = true, //Reading interval flag
4    ctMouseData = "[",
5    ctMouseDataCounter = 0,
6    ctScrollCollected = false,
7    ctEventTokenInterval = null;
8
9ctSetCookie(
10    [
11    {
12        'name' : 'ct_check_js',
13        'value' : ct_check_js_val
14    },
15    {
16        'name' : 'ct_ps_timestamp',
17        'value' : Math.floor(new Date().getTime()/1000)
18    },
19    {
20        'name' : 'ct_fkp_timestamp',
21        'value' : '0'
22    },
23    {
24        'name' : 'ct_pointer_data',
25        'value' : '0'
26    },
27    {
28        'name' : 'ct_timezone',
29        'value' : d.getTimezoneOffset()/60*(-1)
30    },
31    {
32        'name' : 'apbct_antibot',
33        'value' : drupal_ac_antibot_cookie_value
34    },
35    {
36        'name' : 'ct_has_scrolled',
37        'value' : false
38    }
39    ]
40);
41
42//Reading interval
43
44var ctMouseReadInterval = setInterval(
45    function () {
46        ctMouseEventTimerFlag = true;
47    }, 150
48);
49
50//Writting interval
51
52var ctMouseWriteDataInterval = setInterval(
53    function () {
54        /**
55         * Do not write mouse data if alternative sessions or bot detector is used.
56         */
57        const altSessionsUsed = typeof ct_use_alt_cookies !== "undefined" && ct_use_alt_cookies === 1;
58        const botDetectorUsed = typeof ct_use_bot_detector !== "undefined" && ct_use_bot_detector === 1;
59        if( altSessionsUsed || botDetectorUsed ) {
60            return;
61        }
62
63        var ctMouseDataToSend = ctMouseData.slice(0,-1).concat("]");
64        ctSetCookie(
65            [
66            {
67                'name' : 'ct_pointer_data',
68                'value' : ctMouseDataToSend
69            }
70            ]
71        );
72    }, 1200
73);
74
75//Stop observing function
76
77function ctMouseStopData()
78{
79    if(typeof window.addEventListener == "function") {
80        window.removeEventListener("mousemove", ctFunctionMouseMove);
81    } else {
82        window.detachEvent("onmousemove", ctFunctionMouseMove);
83    }
84    clearInterval(ctMouseReadInterval);
85    clearInterval(ctMouseWriteDataInterval);
86}
87
88//Logging mouse position each 300 ms
89
90var ctFunctionMouseMove = function output(event)
91{
92    if (ctMouseEventTimerFlag == true) {
93        var mouseDate = new Date();
94        ctMouseData += "[" + Math.round(event.pageY) + "," + Math.round(event.pageX) + "," + Math.round(mouseDate.getTime() - ctTimeMs) + "],";
95        ctMouseDataCounter++;
96        ctMouseEventTimerFlag = false;
97        if(ctMouseDataCounter >= 100) {
98            ctMouseStopData();
99        }
100    }
101};
102
103/**
104 * Set scrolling cookie
105 */
106function ctSetHasScrolled()
107{
108    if(! ctScrollCollected ) {
109        ctSetCookie(
110            [
111            {
112                'name' : 'ct_has_scrolled',
113                'value' : true
114            }
115            ]
116        );
117        ctScrollCollected = true;
118    }
119}
120
121//Stop key listening function
122
123function ctKeyStopStopListening()
124{
125    if (typeof window.addEventListener == "function") {
126        window.removeEventListener("mousedown", ctFunctionFirstKey);
127        window.removeEventListener("keydown", ctFunctionFirstKey);
128    }
129    else {
130        window.detachEvent("mousedown", ctFunctionFirstKey);
131        window.detachEvent("keydown", ctFunctionFirstKey);
132    }
133}
134
135//Writing first key press timestamp
136
137var ctFunctionFirstKey = function output(event)
138{
139    var KeyTimestamp = Math.floor(new Date().getTime()/1000);
140    ctSetCookie(
141        [
142        {
143            'name' : 'ct_fkp_timestamp',
144            'value' : KeyTimestamp
145        }
146        ]
147    );
148    ctKeyStopStopListening();
149};
150
151if (typeof window.addEventListener == "function") {
152    window.addEventListener("mousemove", ctFunctionMouseMove);
153    window.addEventListener("mousedown", ctFunctionFirstKey);
154    window.addEventListener("keydown", ctFunctionFirstKey);
155    window.addEventListener("scroll", ctSetHasScrolled);
156}
157else {
158    window.attachEvent("onmousemove", ctFunctionMouseMove);
159    window.attachEvent("mousedown", ctFunctionFirstKey);
160    window.attachEvent("keydown", ctFunctionFirstKey);
161    window.attachEvent("scroll", ctSetHasScrolled);
162}
163
164function apbct_collect_visible_fields( form )
165{
166
167    // Get only fields
168    var inputs = [],
169        inputs_visible = '',
170        inputs_visible_count = 0,
171        inputs_invisible = '',
172        inputs_invisible_count = 0,
173        inputs_with_duplicate_names = [];
174
175    for(var key in form.elements){
176        if(!isNaN(+key)) {
177            inputs[key] = form.elements[key];
178        }
179    }
180
181    // Filter fields
182    inputs = inputs.filter(
183        function (elem) {
184
185            // Filter already added fields
186            if(inputs_with_duplicate_names.indexOf(elem.getAttribute('name')) !== -1 ) {
187                return false;
188            }
189            // Filter inputs with same names for type == radio
190            if(-1 !== ['radio', 'checkbox'].indexOf(elem.getAttribute("type"))) {
191                inputs_with_duplicate_names.push(elem.getAttribute('name'));
192                return false;
193            }
194            return true;
195        }
196    );
197
198    // Visible fields
199    inputs.forEach(
200        function (elem, i, elements) {
201            // Unnecessary fields
202            if(elem.getAttribute("type")         === "submit"  // type == submit
203                || elem.getAttribute('name')         === null
204                || elem.getAttribute('name')         === 'ct_checkjs'
205            ) {
206                return;
207            }
208            // Invisible fields
209            if(getComputedStyle(elem).display    === "none"    // hidden
210                || getComputedStyle(elem).visibility === "hidden"  // hidden
211                || getComputedStyle(elem).opacity    === "0"       // hidden
212                || elem.getAttribute("type")         === "hidden" // type == hidden
213            ) {
214                if(elem.classList.contains("wp-editor-area") ) {
215                    inputs_visible += " " + elem.getAttribute("name");
216                    inputs_visible_count++;
217                } else {
218                    inputs_invisible += " " + elem.getAttribute("name");
219                    inputs_invisible_count++;
220                }
221            }
222            // Visible fields
223            else {
224                inputs_visible += " " + elem.getAttribute("name");
225                inputs_visible_count++;
226            }
227
228        }
229    );
230
231    inputs_invisible = inputs_invisible.trim();
232    inputs_visible = inputs_visible.trim();
233
234    return {
235        visible_fields : inputs_visible,
236        visible_fields_count : inputs_visible_count,
237        invisible_fields : inputs_invisible,
238        invisible_fields_count : inputs_invisible_count,
239    }
240
241}
242
243function apbct_visible_fields_set_cookie( visible_fields_collection )
244{
245    var collection = typeof visible_fields_collection === 'object' && visible_fields_collection !== null ?  visible_fields_collection : {};
246
247    ctSetCookie(
248        [
249        {
250            'name' : 'apbct_visible_fields',
251            'value' : JSON.stringify(collection)
252        }
253        ]
254    )
255}
256
257// Event token handler class. Get token and save it to the alternative sessions.
258
259class EventTokenHandler {
260
261  constructor(use_alt_cookies_option) {
262    this.token = null;
263    this.lsSavedFlagName = 'event_token_saved_to_alt_sessions';
264    this.lsEVentTokenName = 'bot_detector_event_token';
265    this.intervalValue = 1500;
266    this.init(use_alt_cookies_option);
267  }
268
269  init(use_alt_cookies_option){
270    if ('undefined' !== typeof use_alt_cookies_option && use_alt_cookies_option) {
271      this.setNotSavedFlag();
272      this.startListenTokenLS();
273    }
274  }
275
276
277  setSavedFlag()
278  {
279    localStorage.setItem(this.lsSavedFlagName, '1');
280  }
281
282  setNotSavedFlag()
283  {
284    localStorage.setItem(this.lsSavedFlagName, '0');
285  }
286
287  isSaved()
288  {
289    let event_token_saved = localStorage.getItem(this.lsSavedFlagName);
290    return event_token_saved !== null && event_token_saved !== undefined && event_token_saved === '1';
291  }
292
293  getEventToken()
294  {
295    let event_token = localStorage.getItem(this.lsEVentTokenName);
296    try {
297      event_token = event_token !== null ? JSON.parse(event_token) : false;
298    } catch (e) {
299      return false;
300    }
301    event_token = event_token.hasOwnProperty('value') ? event_token.value : false;
302    if (typeof event_token === 'string' && event_token.length === 64) {
303      return event_token;
304    }
305    return false;
306  }
307
308  setEventTokenCookie()
309  {
310    if (typeof this.token === 'string' && this.token.length === 64) {
311      ctSetCookie(
312        [
313          {
314            'name': 'apbct_event_token',
315            'value': this.token
316          }
317        ]
318      )
319    }
320  }
321
322  stopListenTokenLS()
323  {
324    clearInterval(this.intervalID);
325  }
326
327  startListenTokenLS()
328  {
329    this.intervalID = setInterval( this.intervalRun, this.intervalValue, this)
330  }
331
332  intervalRun(handler)
333  {
334    if ( !handler.isSaved() ) {
335      handler.token = handler.getEventToken();
336      if ( handler.token  ) {
337        handler.setEventTokenCookie();
338        handler.setSavedFlag();
339        handler.stopListenTokenLS();
340      }
341    }
342  }
343}
344
345//Collect event token
346new EventTokenHandler(ct_use_alt_cookies);

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.