PageSourceSearch

https://adscook.com/resources_adscook/js/main.js?v=1675838910

js adscook.com collected 2026-10-04 09:26:05 UTC 11,670 bytes, 350 lines download raw bytes

1$(document).ready(function () {
2    $("#affiliate-program-btn").click(function () {
3        gtag('event', 'Clicked on Affiliate Program', {
4            event_category: 'Affiliate Click',
5            event_label: 'Affiliate Page Visit'
6        });
7        gtag('event', 'conversion', {send_to: 'AW-777946955/Zf6GCOyMqNsCEMuO-vIC'});
8        fbq('track', 'Affiliate Click');
9    });
10
11    $("#discount-banner").click(function () {
12        gtag('event', 'Clicked on the Banner', {event_category: 'Banner Click'});
13        gtag('event', 'conversion', {send_to: 'AW-777946955/Zf6GCOyMqNsCEMuO-vIC'});
14        fbq('track', 'Banner Click');
15    });
16
17    $('.try-magic-tool-btn').click(function() {
18        gtag('event', 'Clicked on the button', {event_category: 'Magic tool button click', event_label: 'Magic tool button click'});
19    });
20
21    // for timer
22    // function getTimerData() {
23    //     let bannerInfo = '';
24    //     const countDownDate = new Date("August 17, 2022 19:00:00").getTime();
25    //     const distance = countDownDate - new Date().getTime();
26    //     const days = Math.floor(distance / (1000 * 60 * 60 * 24));
27    //     const hours = Math.floor(distance / (1000 * 60 * 60) - (days * 24));
28    //     const minutes = Math.floor(distance / (1000 * 60) - (days * 24 * 60) - (hours * 60));
29    //     const seconds = Math.floor(distance / 1000 - (days * 24 * 60 * 60) - (hours * 60 * 60) - (minutes * 60));
30    //
31    //     days > 0 ? bannerInfo = days + "d : " + hours + "h : " + minutes + "m : " + seconds + "s" :
32    //                 bannerInfo = hours + "h : " + minutes + "m : " + seconds + "s";
33    //
34    //     document.querySelector('#banner-timer-info').innerHTML = bannerInfo;
35    // }
36    //
37    // setInterval(getTimerData, 1);
38
39    const creativeAdOptions = [
40        {
41            url: "option1",
42            isSelected: true
43        },
44        {
45            url: "option2",
46            isSelected: true
47        },
48        {
49            url: "option3",
50            isSelected: true
51        },
52        {
53            url: "option4",
54            isSelected: true
55        },
56        {
57            url: "option5",
58            isSelected: false
59        },
60        {
61            url: "option6",
62            isSelected: false
63        },
64        {
65            url: "option7",
66            isSelected: false
67        },
68        {
69            url: "option8",
70            isSelected: false
71        },
72        {
73            url: "option9",
74            isSelected: false
75        },
76        {
77            url: "option10",
78            isSelected: false
79        },
80        {
81            url: "option11",
82            isSelected: false
83        },
84        {
85            url: "option12",
86            isSelected: false
87        },
88        {
89            url: "option13",
90            isSelected: false
91        },
92        {
93            url: "option14",
94            isSelected: false
95        },
96        {
97            url: "option15",
98            isSelected: false
99        },
100        {
101            url: "option16",
102            isSelected: false
103        },
104        {
105            url: "option17",
106            isSelected: false
107        },
108        {
109            url: "option18",
110            isSelected: false
111        },
112        {
113            url: "option19",
114            isSelected: false
115        }
116    ];
117
118    // gemy
119    const gemyUrl = 'https://gemy.ai';
120    const apiUrl = 'https://api.adscook.com';
121    const uploadLoader = $('#generation-block #uploadLoader');
122    const generationsLoader = $('#generation-block #generationsLoader');
123    const generateLoader = $('#generation-block #generateBtnLoader');
124    const imageOptions = $("#generation-block #productOptions");
125    const uploadedElement = $('#generation-block .generation-block-product-image-uploaded');
126    let uploadedProductId;
127    let productCategoryId = '';
128
129    function showV2Captcha() {
130        return new Promise(resolve => {
131            grecaptcha.ready(() => {
132                $('#v2captcha').show();
133                try {
134                    grecaptcha.render('v2captcha', {
135                        'sitekey': '6Lc0XUojAAAAAPmjO9axkrn_iL-Gq5rgRkBHseLs'
136                    });
137                } catch(err) {}
138                window.verifyV2Callback = () => {
139                    resolve(grecaptcha.getResponse(1));
140                };
141
142                window.errorV2Callback = () => {
143                    resetCaptcha();
144                };
145            });
146        });
147    }
148
149    function showV3Captcha() {
150        return new Promise(resolve => {
151            const generateCaptcha = () => {
152                grecaptcha.ready(() => {
153                    grecaptcha.execute('6LcvQQcaAAAAALMYyBoGQDxwaKinMq4XmZFjdhkG', {action: 'submit'}).then(function(token) {
154                        resolve(token);
155                    }, () => generateCaptcha());
156                });
157            };
158            generateCaptcha();
159        });
160    }
161
162    function emptyOptions() {
163        $("#generation-block #productOptions .generation-block-product-image").remove();
164    }
165
166    function generateImageBlock(src, dataId) {
167        return `<div class="generation-block-product-image">
168                    <img src=${src} alt="" class="generation-block-product-image-image">
169                    <div class="generation-block-product-image--hover">
170                        <button class="btn generation-block-product-image-action generated-product-download" type="button" data-id="${dataId}">
171                            <span class="ads-icon-download"></span>
172                        </button>
173                    </div>
174                </div>`;
175    }
176
177    function setRandomImages() {
178        const shufflableImages = creativeAdOptions.filter(item => !item.isSelected);
179        const shuffled = shufflableImages.sort(() => 0.5 - Math.random());
180        let options = '';
181        emptyOptions();
182        creativeAdOptions.forEach(option => option.isSelected = false);
183        shuffled.slice(0, 4).forEach((image) => {
184            image.isSelected = true;
185            let src = `resources_adscook/images/options/${image.url}.jpg?v=13`;
186            options += generateImageBlock(src, '');
187        });
188
189        imageOptions.append(options);
190    }
191
192    function redirectToGemy(response) {
193        if (response.nocredit) {
194            window.location.href = gemyUrl;
195        }
196    }
197
198    function doGeneration(token, recaptchaV2 = false) {
199        let data = {
200            category: productCategoryId,
201            'g-recaptcha-response': token
202        };
203
204        if (recaptchaV2) {
205            data.recaptcha_v2 = true;
206        }
207        $.ajax({
208            type: "POST",
209            url: `${apiUrl}/api/adgeneration/${uploadedProductId}`,
210            data,
211            dataType: "json",
212            beforeSend: function () {
213                generateLoader.show();
214                generationsLoader.show();
215            }
216        }).done(function (response) {
217            recaptchaV2 && resetCaptcha();
218            redirectToGemy(response);
219            if (response.data) {
220                let options = '';
221                let uploadedImagesCount = 0;
222                emptyOptions();
223                response.data.forEach(image => {
224                    options += generateImageBlock(`${apiUrl}${image.url}`, `${image.id}`);
225                });
226                imageOptions.append(options);
227                $('#generation-block #productOptions img').on('load', function() {
228                    uploadedImagesCount++;
229
230                    if (uploadedImagesCount === $('#generation-block #productOptions img').length) {
231                        generateLoader.hide();
232                        generationsLoader.hide();
233                    }
234                });
235            }   else {
236                generationsLoader.hide();
237            }
238        }).fail((error) => {
239            if (error.status === 412) {
240                showV2Captcha().then(captcha => {
241                    doGeneration(captcha, true);
242                });
243            }   else {
244                generationsLoader.hide();
245            }
246        });
247    }
248
249    function generateOptions() {
250        showV3Captcha().then(token => {
251            doGeneration(token);
252        });
253    }
254
255    $('#generation-block #generateOptions').click(function () {
256        if (uploadedProductId) {
257            generateOptions();
258        }   else {
259            setRandomImages();
260        }
261    });
262
263    function resetCaptcha() {
264        grecaptcha.getResponse(1) && grecaptcha.reset(1);
265        $('#v2captcha').hide();
266    }
267
268    function uploadImage(productFile, token, recaptchaV2 = false) {
269        let data = new FormData();
270        data.append('files', productFile, productFile.name);
271        data.append('type', '1');
272        data.append('g-recaptcha-response', token);
273        if (recaptchaV2) {
274            data.append('recaptcha_v2', true);
275        }
276        $.ajax({
277            type: "POST",
278            url: `${apiUrl}/api/upload/file`,
279            data,
280            dataType: "json",
281            processData: false,
282            contentType: false,
283            beforeSend: function () {
284                uploadLoader.show();
285            }
286        }).done(function (response) {
287            recaptchaV2 && resetCaptcha();
288            if (response.nocredit) {
289                uploadLoader.hide();
290                $('#upload-error-nocredit').show();
291            }   else if (response.data[0]) {
292                uploadedElement.empty();
293                uploadedProductId = response.data[0].id;
294                $('#generation-block #image-upload').hide();
295                $('#generation-block #image-analyze').show();
296
297                setTimeout(function() {
298                    uploadedElement.append(`<img src=${apiUrl}/attachment/${uploadedProductId} class="generation-block-product-image-image">`);
299                    $('#generation-block #uploadedImage img').on('load', function () {
300                        uploadLoader.hide();
301                        $('#generation-block #image-analyze').hide();
302                    });
303                }, 3000);
304            }
305        }).fail(error => {
306            if (error.status === 412) {
307                showV2Captcha().then(captcha => {
308                    uploadImage(productFile, captcha, true);
309                });
310            }   else {
311                uploadLoader.hide();
312            }
313        });
314    }
315
316    $('#generation-block #uploadProduct input').change(function () {
317        let productFile = this.files[0];
318        let validTypes = ['image/jpg', 'image/jpeg', 'image/png'];
319
320        if (productFile) {
321            $('#upload-error').hide();
322            $('#generation-block #image-upload').show();
323
324            if (validTypes.includes(productFile.type)) {
325                showV3Captcha().then((token) => {
326                    uploadImage(productFile, token);
327                });
328            }   else {
329                uploadLoader.show();
330                $('#generation-block #image-upload').show();
331
332                setTimeout(function() {
333                    uploadLoader.hide();
334                    $('#upload-error').show();
335                }, 3000);
336            }
337        }
338    });
339
340    $('#generation-block #product-category .dropdown-menu').on('click', '.dropdown-item', function() {
341        productCategoryId = $(this).data('product-id');
342        $('#product-category .filter-option-inner--left').empty().append($(this).clone());
343    });
344
345
346    imageOptions.on('click', '.generated-product-download', function () {
347        let elementId = $(this).data('id') || '';
348        elementId ? window.open(`${gemyUrl}?variation_id=${elementId}`, '_blank') : window.open(`${gemyUrl}`, '_blank');
349    });
350});

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.