PageSourceSearch

https://avpn.asia/conference/wp-content/plugins/handl-utm-grabber/js/handl-utm-grabber.js?ver=2.9.11

js avpn.asia collected 2026-09-24 09:22:11 UTC 5,134 bytes, 157 lines download raw bytes

1var qvars = getUrlVars()
2var handlConsentGranted = typeof handl_utm_cookie_duration === 'undefined' || handl_utm_cookie_duration[1] === '1'
3
4jQuery(function($) {
5    if (handlConsentGranted) {
6        RunHandL()
7    }
8});
9
10function RunHandL(){
11    handlConsentGranted = true
12    setHandLParams()
13    RunFieldFiller()
14    HandLAppendTrackedLinks()
15}
16
17// IP stays server-side.
18function setHandLParams(){
19    var cookieOptions = { expires: parseInt(handl_utm_cookie_duration[0]) }
20
21    Cookies.set('handl_url', document.location.href, cookieOptions)
22    Cookies.set('handl_ref', document.referrer, cookieOptions)
23
24    if (Cookies.get('handl_landing_page') === undefined) {
25        Cookies.set('handl_landing_page', document.location.href, cookieOptions)
26    }
27
28    if (Cookies.get('handl_original_ref') === undefined) {
29        Cookies.set('handl_original_ref', document.referrer, cookieOptions)
30    }
31}
32
33function HandLAppendTrackedLinks(){
34    jQuery('.utm-out').each(function(){
35        // Only process if this is an anchor tag with href
36        if (this.tagName.toLowerCase() !== 'a' || !this.href) {
37            return;
38        }
39
40        // Sanitize URL parameters and handl_utm object
41        var urlParams = getSearchParams(this.href);
42        var sanitizedParams = {};
43
44        // Only include parameters that exist in handl_utm
45        for(var key in urlParams) {
46            if(handl_utm.hasOwnProperty(key)) {
47                sanitizedParams[key] = encodeURIComponent(urlParams[key]);
48            }
49        }
50
51        // Sanitize handl_utm values
52        var sanitizedHandlUtm = {};
53        for(var key in handl_utm) {
54            sanitizedHandlUtm[key] = encodeURIComponent(handl_utm[key]);
55        }
56
57        // Merge sanitized objects
58        var merged = jQuery.extend({}, sanitizedHandlUtm, sanitizedParams);
59
60        // Reset href and append sanitized parameters
61        this.href = this.href.split('?')[0]; // Keep base URL only
62        if(!jQuery.isEmptyObject(merged)) {
63            this.href += "?" + jQuery.param(merged);
64        }
65    });
66}
67
68// WP Consent API
69document.addEventListener('wp_listen_for_consent_change', function (e) {
70    var changedConsentCategory = e.detail;
71    for (var key in changedConsentCategory) {
72        if (changedConsentCategory.hasOwnProperty(key)) {
73            if (key === 'marketing' && changedConsentCategory[key] === 'allow') {
74                console.log('WP Consent API: Marketing consent granted, running HandL');
75                RunHandL();
76            }
77        }
78    }
79});
80
81function RunFieldFiller(){
82    jQuery.each([ 'utm_source','utm_medium','utm_term', 'utm_content', 'utm_campaign', 'gclid', 'handl_landing_page', 'handl_original_ref', 'handl_ip', 'handl_ref', 'handl_url', 'email', 'username' ], function( i,v ) {
83
84        var cookie_field = GetQVars(v,qvars)
85
86        if ( cookie_field != '' )
87            Cookies.set(v, cookie_field, { expires: 30 });
88
89        var curval = Cookies.get(v)
90
91        if (curval != undefined) {
92            curval = decodeURIComponent(curval).replace(/[%]/g,' ')
93
94            if ([ 'utm_source', 'utm_medium', 'utm_term', 'utm_content', 'utm_campaign', 'gclid' ].indexOf(v) !== -1) {
95                handl_utm[v] = curval
96            }
97
98            if (v == 'username') {
99                //Maybe this should apply to all... We'll see...
100                curval = curval.replace(/\+/g, ' ')
101            }
102
103            jQuery('input[name=\"'+v+'\"]').val(curval)
104            jQuery('input#'+v).val(curval)
105            jQuery('input.'+v).val(curval)
106            jQuery('input#form-field-'+v).val(curval)
107
108            //for nested input fix
109            jQuery('#'+v).find('input').val(curval)
110            jQuery('.'+v).find('input').val(curval)
111
112            jQuery("[data-original_id='"+v+"']").val(curval)
113            jQuery("[data-name='"+v+"']").val(curval)
114            jQuery("[data-name='"+v.replace(/_/g,'')+"']").val(curval) //Active Campaign
115            jQuery("[placeholder='"+v+"']").val(curval) //Dyanmics 365 + Generic
116
117            if (v.length > 4 && ['email','username'].indexOf(v) == -1){ // this is for making sure wildcards are not hyper sensitive. (email/username are free-only params, V3 never wildcards them)
118                //wildcard selector
119                jQuery("[name*="+v+"]").val(curval)
120                jQuery("[id*="+v+"]").val(curval)
121                jQuery("[class*="+v+"]").val(curval)
122            }
123
124        }
125    });
126}
127
128function getSearchParams(url,k){
129    var p={};
130    var a = document.createElement('a');
131    a.href = url;
132    a.search.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(s,k,v){p[k]=v})
133    return k?p[k]:p;
134}
135
136function GetQVars(v,qvars){
137    if (qvars[v] != undefined) {
138        return qvars[v]
139    }
140    return ''
141}
142
143function getUrlVars() {
144    var vars = {};
145    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
146        vars[key] = value;
147    });
148    return vars;
149}
150
151jQuery( document ).on( 'elementor/popup/show' , function () {
152    setTimeout(function(){
153        if (handlConsentGranted) {
154            RunFieldFiller()
155        }
156    }, 1000)
157} );

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.