PageSourceSearch

https://mbsugars.com/wp-content/plugins/handl-utm-grabber/js/handl-utm-grabber.js?ver=6.8.10

js mbsugars.com collected 2026-10-08 06:39:29 UTC 2,432 bytes, 81 lines download raw bytes

1jQuery(function($) {
2    var qvars = getUrlVars()
3
4    $.each([ 'utm_source','utm_medium','utm_term', 'utm_content', 'utm_campaign', 'gclid', 'email', 'username' ], function( i,v ) {
5
6        var cookie_field = GetQVars(v,qvars)
7
8        if ( cookie_field != '' )
9            Cookies.set(v, cookie_field, { expires: 30 });
10
11        var curval = Cookies.get(v)
12
13        if (curval != undefined) {
14            curval = decodeURIComponent(curval).replace(/[%]/g,' ')
15            if (v == 'username') {
16                //Maybe this should apply to all... We'll see...
17                curval = curval.replace(/\+/g, ' ')
18            }
19
20            jQuery('input[name=\"'+v+'\"]').val(curval)
21            jQuery('input#'+v).val(curval)
22            jQuery('input.'+v).val(curval)
23        }
24    });
25
26    $('.utm-out').each(function(){
27        // Only process if this is an anchor tag with href
28        if (this.tagName.toLowerCase() !== 'a' || !this.href) {
29            return;
30        }
31        
32        // Sanitize URL parameters and handl_utm object
33        var urlParams = getSearchParams(this.href);
34        var sanitizedParams = {};
35        
36        // Only include parameters that exist in handl_utm
37        for(var key in urlParams) {
38            if(handl_utm.hasOwnProperty(key)) {
39                sanitizedParams[key] = encodeURIComponent(urlParams[key]);
40            }
41        }
42        
43        // Sanitize handl_utm values
44        var sanitizedHandlUtm = {};
45        for(var key in handl_utm) {
46            sanitizedHandlUtm[key] = encodeURIComponent(handl_utm[key]);
47        }
48
49        // Merge sanitized objects
50        var merged = $.extend({}, sanitizedHandlUtm, sanitizedParams);
51        
52        // Reset href and append sanitized parameters
53        this.href = this.href.split('?')[0]; // Keep base URL only
54        if(!$.isEmptyObject(merged)) {
55            this.href += "?" + $.param(merged);
56        }
57    });
58});
59
60function getSearchParams(url,k){
61    var p={};
62    var a = document.createElement('a');
63    a.href = url;
64    a.search.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(s,k,v){p[k]=v})
65    return k?p[k]:p;
66}
67
68function GetQVars(v,qvars){
69    if (qvars[v] != undefined) {
70        return qvars[v]
71    }
72    return ''
73}
74
75function getUrlVars() {
76    var vars = {};
77    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
78        vars[key] = value;
79    });
80    return vars;
81}

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.