PageSourceSearch

https://artvinyl.com/wp-content/plugins/pixelyoursite-pinterest/dist/scripts/public.js?ver=5.5.1.1

js artvinyl.com collected 2026-10-02 09:53:49 UTC 17,545 bytes, 413 lines download raw bytes

1/* global pysOptions */
2!function ($) {
3
4    var Pinterest = function () {
5
6        var initialized = false;
7
8        function getUtils() {
9            return window.pys.Utils;
10        }
11
12        function getOptions() {
13            return window.pysOptions;
14        }
15
16        var notCachedEventsIds = new Array();
17        var isAddToCartFromJs = getOptions().woo.hasOwnProperty("addToCartCatchMethod")
18            && getOptions().woo.addToCartCatchMethod === "add_cart_js";
19        if (!isAddToCartFromJs) {
20            notCachedEventsIds.push('woo_add_to_cart_on_button_click')
21        }
22
23        function fireEvent(name, event) {
24
25            if(typeof window.pys_event_data_filter === "function" && window.pys_disable_event_filter(name,'pinterest')) {
26                return;
27            }
28
29            var data = event.params;
30            var ids = event.pixelIds.filter(function (pixelId) {
31                if (getUtils().hasOwnProperty('hideMatchingPixel')) {
32                    return !getUtils().hideMatchingPixel(pixelId, 'pinterest');
33                }else{
34                    return true;
35                }
36            });
37            if (ids.length) {
38                var params = {};
39
40
41                window.pys.Utils.copyProperties(data, params);
42                window.pys.Utils.copyProperties(window.pys.Utils.getRequestParam
42s(), params);
43
44                if (getOptions().pinterest.serverApiEnabled) {
45
46					if(!isAddToCartFromJs && event.e_id === "woo_add_to_cart_on_button_click" ) {
47						Pinterest.updateEventId(event.name);
48                    	event.eventID = getUtils().generateUniqueId(event);
49                	} else if(!notCachedEventsIds.includes(event.e_id)) {
50
51                        var isApiDisabled = getOptions().gdpr.all_disabled_by_api ||
52                            getOptions().gdpr.facebook_disabled_by_api ||
53                            getOptions().gdpr.tiktok_disabled_by_api ||
54                            getOptions().gdpr.cookiebot_integration_enabled ||
55                            getOptions().gdpr.cookie_notice_integration_enabled ||
56                            getOptions().gdpr.consent_magic_integration_enabled ||
57                            getOptions().gdpr.cookie_law_info_integration_enabled;
58                        // Update eventID
59
60                        event.eventID = getUtils().generateUniqueId(event);
61
62                        // send event from server if they was bloc by gdpr or need send with delay
63                        if (getOptions().ajaxForServerEvent || isApiDisabled || event.delay > 0 || event.type !== "static") {
64
65                            var json = {
66                                action: 'pys_pinterest_api_event',
67                                pixel: Pinterest.tag(),
68                                event: name,
69                                ids: ids,
70                                data: params,
71                                url: window.location.href,
72                                eventID: event.eventID,
73                                ajax_event: getOptions().ajax_event
74                            };
75
76                            if (event.hasOwnProperty('woo_order')) {
77                                json['woo_order'] = event.woo_order;
78                            }
79
80                            if (event.hasOwnProperty('edd_order')) {
81                                json['edd_order'] = event.edd_order;
82                            }
83                            if (event.e_id === "automatic_event_internal_link"
84                                || event.e_id === "automatic_event_outbound_link"
85                                || name == 'PageView'
86                            ) {
87                                setTimeout(function () {
88                                    jQuery.ajax({
89                                        type: 'POST',
90                                        url: getOptions().ajaxUrl,
91                                        data: json,
92                                        headers: {
93                                            'Cache-Control': 'no-cache'
94                                        },
95                                        success: function () {
96                                        },
97                                    });
98                                }, 500)
99                            } else {
100                                jQuery.ajax({
101                                    type: 'POST',
102                                    url: getOptions().ajaxUrl,
103                                    data: json,
104                                    headers: {
105                                        'Cache-Control': 'no-cache'
106                                    },
107                                    success: function () {
108                                    },
109                                });
110                            }
111                        }
112                    }
113                }
114                params.eventID = event.eventID;
115
116                if (getOptions().debug) {
117                    console.log('[Pinterest] ' + name, params);
118                }
119
120                pintrk('track', name, params);
121            }
122        }
123
124        /**
125         * Public API
126         */
127        return {
128            tag: function() {
129                return "pinterest";
130            },
131            isEnabled: function () {
132                return getOptions().hasOwnProperty('pinterest');
133            },
134            getHidePixel: function(){
135                if(this.isEnabled() && getOptions().pinterest.hasOwnProperty('hide_pixels'))
136                {
137                    return getOptions().pinterest.hide_pixels;
138                }
139                return [];
140            },
141            disable: function () {
142                initialized = false;
143            },
144            initEventIdCookies: function (key) {
145                var ids = {};
146                ids[key] = pys_generate_token(36)
147                Cookies.set('pys_pinterest_event_id', JSON.stringify(ids));
148            },
149
150            updateEventId:function(key) {
151                var cooData = Cookies.get("pys_pinterest_event_id")
152                if(cooData === undefined) {
153                    this.initEventIdCookies(key);
154                } else {
155                    var data = JSON.parse(cooData);
156                    data[key] = pys_generate_token(36);
157                    Cookies.set('pys_pinterest_event_id', JSON.stringify(data) );
158                }
159            },
160
161            getEventId:function (key) {
162                var data = Cookies.get("pys_pinterest_event_id");
163                if(data === undefined) {
164                    this.initEventIdCookies(key);
165                    data = Cookies.get("pys_pinterest_event_id");
166                }
167                return JSON.parse(data)[key];
168            },
169            /**
170             * Load pixel's JS
171             *
172             * @link: https://developers.pinterest.com/docs/ad-tools/enhanced-match/
173             */
174            loadPixel: function () {
175
176                if (initialized || !this.isEnabled() || !getUtils().consentGiven('pinterest')) {
177                    return;
178                }
179                var tagId = getOptions().pinterest.pixelIds;
180                tagId = tagId.filter(function (pixelId) {
181                    if (getUtils().hasOwnProperty('hideMatchingPixel')) {
182                        return !getUtils().hideMatchingPixel(pixelId, 'pinterest');
183                    }else{
184                        return true;
185                    }
186
187                });
188                if(tagId.length > 0 ) {
189                    !function (e) {
190                        if (!window.pintrk) {
191                            window.pintrk = function () {
192                                window.pintrk.queue.push(Array.prototype.slice.call(arguments))
193                            };
194                            var n = window.pintrk;
195                            n.queue = [], n.version = "3.0";
196                            var t = document.createElement("script");
197                            t.async = !0, t.src = e;
198                            var r = document.getElementsByTagName("script")[0];
199                            r.parentNode.insertBefore(t, r)
200                        }
201                    }("https://s.pinimg.com/ct/core.js");
202
203                    // initialize pixel
204                    tagId.forEach(function (pixelId) {
205                        pintrk('load', pixelId, {em: getOptions().pinterest.advancedMatching.em, external_id: getOptions().pinterest.advancedMatching.external_id, np: 'pixelyoursite'});
206                        pintrk('page');
207                    });
208
209                    initialized = true;
210
211                    getUtils().fireStaticEvents('pinterest');
212                }
213            },
214
215            fireEvent: function (name, data) {
216
217                if (!initialized || !this.isEnabled()) {
218                    return false;
219                }
220
221                data.delay = data.delay || 0;
222                data.params = data.params || {};
223
224                if (data.delay === 0) {
225
226                    fireEvent(name, data);
227
228                } else {
229
230                    setTimeout(function (name, params) {
231                        fireEvent(name, params);
232                    }, data.delay * 1000, name, data);
233
234                }
235
236
237            },
238
239            onAdSenseEvent: function (event) {
240                this.fireEvent(event.name, event);
241            },
242
243            onClickEvent: function (event) {
244                this.fireEvent(event.name, event);
245            },
246
247            onWatchVideo: function (event) {
248                this.fireEvent(event.name, event);
249            },
250
251            onCommentEvent: function (event) {
252                this.fireEvent(event.name, event);
253            },
254
255            onFormEvent: function (event) {
256                this.fireEvent(event.name, event);
257            },
258
259            onDownloadEvent: function (event) {
260                this.fireEvent(event.name, event);
261            },
262
263            onWooAddToCartOnButtonEvent: function (product_id) {
264                if(!getOptions().dynamicEvents.woo_add_to_cart_on_button_click.hasOwnProperty(this.tag()))
265                    return;
266
267                if (window.pysWooProductData.hasOwnProperty(product_id)) {
268                    if (window.pysWooProductData[product_id].hasOwnProperty('pinterest')) {
269
270                        var event = getUtils().clone(getOptions().dynamicEvents.woo_add_to_cart_on_button_click[this.tag()]);
271                        getUtils().copyProperties(window.pysWooProductData[product_id]['pinterest'].params, event.params);
272                        this.fireEvent(event.name, event);
273
274                    }
275                }
276
277            },
278
279            onWooAddToCartOnSingleEvent: function (product_id, qty, product_type, is_external, $form) {
280
281                window.pys_woo_product_data = window.pys_woo_product_data || [];
282
283                if(!getOptions().dynamicEvents.woo_add_to_cart_on_button_click.hasOwnProperty(this.tag()))
284                    return;
285
286
287                if (product_type === getUtils().PRODUCT_VARIABLE && !getOptions().pinterest.wooVariableAsSimple) {
288                    product_id = parseInt($form.find('input[name="variation_id"]').val());
289                }
290
291                if (window.pysWooProductData.hasOwnProperty(product_id)) {
292                    if (window.pysWooProductData[product_id].hasOwnProperty('pinterest')) {
293
294                        var event = getUtils().clone(getOptions().dynamicEvents.woo_add_to_cart_on_button_click[this.tag()])
295                        getUtils().copyProperties(window.pysWooProductData[product_id]['pinterest'].params, event.params);
296
297                        if(product_type === getUtils().PRODUCT_GROUPED ) {
298                            var total = 0;
299                            $form.find(".woocommerce-grouped-product-list .qty").each(function(index){
300                                var childId = $(this).attr('name').replaceAll("quantity[","").replaceAll("]","");
301                                var quantity = parseInt($(this).val());
302                                if(isNaN(quantity)) {
303                                    quantity = 0;
304                                }
305                                var price = window.pysWooProductData[product_id]['pinterest'].grouped[childId].price;
306                                total += price * quantity;
307                            });
308                            if(total == 0) return;// skip if no items selected
309                            if(getOptions().woo.addToCartOnButtonValueEnabled &&
310                                getOptions().woo.addToCartOnButtonValueOption !== 'global') {
311                                event.params.value = total;
312                            }
313                        } else {
314                            // maybe customize value option
315                            if (getOptions().woo.addToCartOnButtonValueEnabled &&
316                                getOptions().woo.addToCartOnButtonValueOption !== 'global') {
317                                event.params.value = event.params.value * qty;
318                            }
319                        }
320                        event.params.product_quantity = qty;
321
322
323                        if(product_type === getUtils().PRODUCT_BUNDLE) {
324                            var data = $(".bundle_form .bundle_data").data("bundle_form_data");
325                            var items_sum = getBundlePriceOnSingleProduct(data);
326                            var price = (data.base_price+items_sum )* qty;
327                            if (getOptions().woo.addToCartOnButtonValueEnabled && getOptions().woo.addToCartOnButtonValueOption !== 'global') {
328                                event.params.value = price;
329                            }
330                        }
331
332                        var event_name = is_external ? getOptions().woo.affiliateEventName : event.name;
333
334                        this.fireEvent(event_name, event);
335                    }
336                }
337            },
338
339            onWooRemoveFromCartEvent: function (event) {
340                this.fireEvent(event.name, event);
341            },
342
343            onWooAffiliateEvent: function (product_id) {
344                if(!getOptions().dynamicEvents.woo_affiliate.hasOwnProperty(this.tag()))
345                    return;
346                var event = getOptions().dynamicEvents.woo_affiliate[this.tag()];
347
348                if (window.pysWooProductData.hasOwnProperty(product_id)) {
349                    if (window.pysWooProductData[product_id].hasOwnProperty('pinterest')) {
350
351                        event = getUtils().copyProperties(event, {})
352                        getUtils().copyProperties(window.pysWooProductData[product_id][this.tag()].params, event.params)
353                        this.fireEvent( getOptions().woo.affiliateEventName, event);
354
355                    }
356                }
357            },
358
359            onWooPayPalEvent: function (event) {
360                this.fireEvent(event.name, event);
361            },
362
363            onEddAddToCartOnButtonEvent: function (download_id, price_index, qty) {
364                if(!getOptions().dynamicEvents.edd_add_to_cart_on_button_click.hasOwnProperty(this.tag()))
365                    return;
366                var event = getOptions().dynamicEvents.edd_add_to_cart_on_button_click[this.tag()];
367
368                if (window.pysEddProductData.hasOwnProperty(download_id)) {
369
370                    var index;
371
372                    if (price_index) {
373                        index = download_id + '_' + price_index;
374                    } else {
375                        index = download_id;
376                    }
377
378                    if (window.pysEddProductData[download_id].hasOwnProperty(index)) {
379                        if (window.pysEddProductData[download_id][index].hasOwnProperty('pinterest')) {
380
381                            event = getUtils().copyProperties(event, {})
382                            getUtils().copyProperties(window.pysEddProductData[download_id][index]['pinterest'].params, event.params);
383
384                            // maybe customize value option
385                            if (getOptions().edd.addToCartOnButtonValueEnabled && getOptions().edd.addToCartOnButtonValueOption !== 'global') {
386                                event.params.value = event.params.value * qty;
387                            }
388
389                            event.params.product_quantity = qty;
390                            this.fireEvent(event.name,event);
391                        }
392                    }
393                }
394            },
395
396            onEddRemoveFromCartEvent: function (event) {
397                this.fireEvent(event.name, event);
398            },
399            onPageScroll: function (event) {
400                this.fireEvent(event.name, event);
401            },
402            onTime: function (event) {
403                this.fireEvent(event.name, event);
404            },
405
406        };
407
408    }(jQuery);
409
410    window.pys = window.pys || {};
411    window.pys.Pinterest = Pinterest;
412
413}(jQuery);

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.