This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (async () => { | |
| const https = require('https') | |
| const BEARER_TOKEN = '9a2715843372050bafa3c118bfbd9a6a' | |
| try { | |
| let response = await getActiveZones() | |
| let zones = JSON.parse(response.body) | |
| let resZones = zones.map(z => z.name).filter(r => r.includes('captcha_buster')) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let productId = '47095835' | |
| let apiKey = 'feaf228eb2777fd3eee0fd5192ae7107d6224b39' | |
| console.log('performing request') | |
| let data = await page.evaluate(async (productId, apiKey) => { | |
| let response = await fetch(`https://carts.target.com/web_checkouts/v1/cart_items?field_groups=CART%2CCART_ITEMS%2CSUMMARY&key=${apiKey}`, { | |
| "body": `{\"cart_item\":{\"item_channel_id\":\"10\",\"tcin\":\"${productId}\",\"quantity\":1},\"fulfillment\":{\"type\":\"PICKUP\",\"location_id\":1771,\"ship_method\":\"STORE_PICKUP\"},\"cart_type\":\"REGULAR\",\"channel_id\":\"10\",\"shopping_context\":\"DIGITAL\"}`, | |
| "method": "POST", | |
| "mode": "cors", | |
| "credentials": "include", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| App.events = { | |
| // the very first event that gets called as soon as the page appears, but before any | |
| // HTTP calls are made, or any processing is done | |
| beforeCampaignLoaded: () => { }, | |
| // called after HTTP requests are made for the Campaign data (including retailers) but before | |
| // any page rendering is done. Use this opportunity to manipulate the "data" object | |
| // which includes ".campaign" and ".retailers" before sending it on. | |
| campaignLoading: (data, callback) => { | |
| callback(data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| App.events = { | |
| afterCampaignLoaded: (campaign, retailers, previewCollections) => { | |
| !function (f, b, e, v, n, t, s) { | |
| if (f.fbq) return; n = f.fbq = function () { | |
| n.callMethod ? | |
| n.callMethod.apply(n, arguments) : n.queue.push(arguments) | |
| }; | |
| if (!f._fbq) f._fbq = n; n.push = n; n.loaded = !0; n.version = '2.0'; | |
| n.queue = []; t = b.createElement(e); t.async = !0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function addTrackingPixel(src, h, w) { | |
| let height = h || 1 | |
| let width = w || 1 | |
| let img = document.createElement("img"); | |
| img.width = width | |
| img.height = height | |
| img.src = src; | |
| document.body.appendChild(img); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| response = await page.evaluate(async (url) => { | |
| let res = await fetch(url) | |
| let data = await res.json() | |
| return data | |
| }, url); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| urls = [] | |
| urls = getStoreUrls | |
| (async () => { | |
| stores = [] | |
| for (let url of urls) { | |
| try { | |
| const browser = await puppeteer.launch({ headless: false }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div> | |
| <style> | |
| #theball { | |
| position: absolute; | |
| z-index: 2 | |
| } | |
| #theball.hidden { | |
| z-index: 0 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| await page.goto(url, { | |
| waitUntil: ['domcontentloaded'] | |
| }) | |
| await page.waitForFunction('.main_image', n => n.getAttribute('src').length > 0) | |
| //Or sometimes this simpler selector is enough | |
| await page.waitForSelector('.main_image[src]') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| const cheerio = require('cheerio'); | |
| const apiUtils = local('/lib/apiUtils'); | |
| const request = local('/lib/requestUtils'); | |
| const utils = local('/lib/utils'); | |
| const unitsParser = local('/lib/unitsParser'); | |
| const SearchResponse = local('/restApi/responses/SearchResponse'); | |
| const statusCodes = local('/lib/apiStatusCodes'); |