PageSourceSearch

https://www.swaddlesnbottles.com/wp-content/plugins/track-the-click/public/js/track-the-click-public.js

js swaddlesnbottles.com collected 2026-09-26 03:10:30 UTC 2,460 bytes, 87 lines download raw bytes

1(function( $ ) {
2	window.cachebreak = 1;
3
4	function getAnchor(element, textOnly = false) {
5		var anchor = element.innerText;
6		if ( anchor.length == 0 && textOnly == false) {
7			anchor = element.innerHTML.trim();
8			if ( typeof( element.children ) !== 'undefined') {
9				if ( element.children.length > 0 ) {
10					if ( element.children[0].tagName == 'IMG' ) {
11						anchor = 'image:' + element.children[0].src;
12					}
13				}
14			}
15		}
16		return anchor;
17	}
18
19	function processAs() {
20		if (showClickCounts()) {
21			var data = new FormData();
22			data.append("postID", getPostID());
23			data.append("location", window.location);
24			var url = getHomeURL() + '/wp-json/track-the-click/v3/getpagelinkclicks/' + window.cachebreak++;
25
26			jQuery.ajax({
27				url: url,
28				type: "POST",
29				data: data,
30				contentType: false,
31				processData: false,
32				cache: false,
33				beforeSend: function ( xhr ) {
34					xhr.setRequestHeader( 'X-WP-Nonce', ajax_var.nonce );
35				},
36				success: function(newdata) {
37					if (newdata !== false) {
38						var as = document.getElementsByTagName("a");
39						Array.from(as, a => {
40							newdata.forEach(clickCount => {
41								if (a.href == clickCount.target && getAnchor(a) == clickCount.anchor && clickCount.clicks > 0) {
42									a.setAttribute("data-clicks", clickCount.clicks);
43								}
44							});
45						});
46					}
47				},
48				error: function(error) {
49					console.error(error);
50				}
51			});
52		}
53
54		var as = document.getElementsByTagName("a");
55		Array.from(as, a => {
56			// If the pro version of the plugin is installed, process A tags
57			if ( typeof( proProcessLinks ) == 'function' ) {
58				proProcessLinks( a );
59			}
60		})
61	}
62
63	function bubbleBeacon(event) {
64		if (!ttc_data.proBeacon) {
65			if (event.target.closest('A')) {
66				closestA = event.target.closest('A')
67				// There is an A at or above this level in the DOM
68				// ie. they've clicked a link
69				var data = new FormData();
70				data.append("postID", getPostID());
71				data.append("location", window.location);
72				data.append("anchor", getAnchor(closestA));
73				data.append("target", closestA.href);
74				var url = getHomeURL() + '/wp-json/track-the-click/v3/click/' + window.cachebreak++;
75				navigator.sendBeacon(url, data);
76			}
77		}
78	}
79
80	if (document.readyState === 'loading') {
81		document.addEventListener("DOMContentLoaded", processAs);
82	} else {
83		processAs();
84	}
85	document.addEventListener("click", bubbleBeacon);
86	document.addEventListener("auxclick", bubbleBeacon);
87})();

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.