11// ==UserScript==
22// @name Best Buy - Cart Saved Items Automation
33// @namespace akito
4- // @version 3.2.1
4+ // @version 3.2.2
55// @author akito#9528 / Albert Sun
66// @require https://raw.githubusercontent.com/albert-sun/tamper-scripts/bestbuy-cart_3.2/bestbuy-cart/user_interface.js
77// @require https://raw.githubusercontent.com/albert-sun/tamper-scripts/bestbuy-cart_3.2/bestbuy-cart/constants.js
2323/* globals $, __META_LAYER_META_DATA, constants */
2424/* globals generateInterface, generateWindow, designateSettings, designateLogging*/
2525
26- const scriptVersion = "3.2.1 " ;
26+ const scriptVersion = "3.2.2 " ;
2727const scriptPrefix = "BestBuy-CartSavedItems" ;
2828const scriptText = `Best Buy - Cart Saved Items Automation v${ scriptVersion } | akito#9528 / Albert Sun` ;
2929const messageText = `Thanks and good luck! | <a href="https://www.paypal.com/donate?business=GFVTB9U2UGDL6¤cy_code=USD">Donate via PayPal</a>` ;
@@ -114,21 +114,21 @@ async function initialize() {
114114 whitelistKeywords = settings . whitelistKeywords . value ;
115115 if ( Array . isArray ( whitelistKeywords ) === false ) { throw new Error ( "not an array" ) ; }
116116 } catch ( err ) {
117- loggingFunction ( `/!\\ Error parsing whitelisted keywords: ${ err . message } ` ) ;
117+ loggingFunction ( `/!\\ Error parsing whitelisted keywords: { ${ err . message } }` ) ;
118118 return false ;
119119 }
120120 try { // Attempt to parse and set blacklisted keywords
121121 blacklistKeywords = settings . blacklistKeywords . value ;
122122 if ( Array . isArray ( blacklistKeywords ) === false ) { throw new Error ( "not an array" ) ; }
123123 } catch ( err ) {
124- loggingFunction ( `/!\\ Error parsing blacklisted keywords: ${ err . message } ` ) ;
124+ loggingFunction ( `/!\\ Error parsing blacklisted keywords: { ${ err . message } }` ) ;
125125 return false ;
126126 }
127127 try { // Attempt to parse and set whitelisted SKUs
128128 whitelistSKUs = settings . whitelistSKUs . value ;
129129 if ( Array . isArray ( whitelistSKUs ) === false ) { throw new Error ( "not an array" ) ; }
130130 } catch ( err ) {
131- loggingFunction ( `/!\\ Error parsing whitelisted SKUs: ${ err . message } ` ) ;
131+ loggingFunction ( `/!\\ Error parsing whitelisted SKUs: { ${ err . message } }` ) ;
132132 return false ;
133133 }
134134
@@ -182,7 +182,7 @@ async function trackSaved() {
182182 . map ( descriptionElement => descriptionElement . innerText ) ;
183183 const savedButtons = $ ( ".saved-items__card-wrapper .btn.btn-block" ) . toArray ( ) ;
184184
185- loggingFunction ( `${ savedSKUs . length } saved items found, filtering through whitelist and blacklist` ) ;
185+ loggingFunction ( `{ ${ savedSKUs . length } } saved items found, filtering through whitelist and blacklist` ) ;
186186
187187 // Parse keywords / SKUs for each and splice blacklisted or non-whitelisted
188188 let index = savedSKUs . length ;
@@ -207,13 +207,15 @@ async function trackSaved() {
207207
208208 // If don't track item, splice from array
209209 if ( valid === false ) {
210+ loggingFunction ( `Script not tracking { ${ description } } as either blacklisted or unwhitelisted` ) ;
211+
210212 savedSKUs . splice ( index , 1 ) ;
211213 savedDescriptions . splice ( index , 1 ) ;
212214 savedButtons . splice ( index , 1 ) ;
213215 }
214216 }
215217
216- loggingFunction ( `Finished filtering whitelisted items, ${ savedSKUs . length } items remaining` ) ;
218+ loggingFunction ( `Finished filtering whitelisted items, { ${ savedSKUs . length } } items remaining` ) ;
217219 loggingFunction ( `Initializing polling interval for auto-clicking items with clickable buttons` ) ;
218220
219221 // Iterate through remaining and check which ones are clickable / queued
@@ -227,7 +229,7 @@ async function trackSaved() {
227229 // Honestly ignoring anything that says "Find a Store" since the script can't choose stores
228230 if ( button . innerText === "Add to Cart" ) {
229231 if ( buttonColor === "grey" ) {
230- loggingFunction ( `Currently queued: ${ description } ` ) ;
232+ loggingFunction ( `Currently queued: { ${ description } }` ) ;
231233 }
232234
233235 trackedItems [ sku ] = {
@@ -252,7 +254,7 @@ async function trackSaved() {
252254 for ( const [ sku , trackedInfo ] of Object . entries ( trackedItems ) ) {
253255 trackedInfo . color = elementColor ( trackedInfo . button ) ;
254256 if ( trackedInfo . color === "white" || trackedInfo . color === "blue" || trackedInfo . color === "yellow" ) {
255- loggingFunction ( `Clickable initial / popped: ${ trackedInfo . description } ` ) ;
257+ loggingFunction ( `Clickable initial / popped: { ${ trackedInfo . description } }` ) ;
256258
257259 // Check current ignore status and process if enabled
258260 // TODO: check error message popup instead of doing this ignore stuff
@@ -296,7 +298,7 @@ async function trackSaved() {
296298 GM_setValue ( `${ scriptPrefix } _sentQueueCodes` , sentQueueCodes ) ;
297299
298300 // Sending repeat queues shouldn't matter that much honestly, Cloudflare is generous?
299- loggingFunction ( `Sending queue analytics for saved item with SKU ${ sku } ` ) ;
301+ loggingFunction ( `Sending queue analytics for saved item with SKU { ${ sku } }` ) ;
300302 await fetch ( "https://bestbuy-queue-analytics.akitocodes.workers.dev/" , {
301303 method : "POST" ,
302304 body : JSON . stringify ( {
@@ -356,15 +358,15 @@ async function main() {
356358 }
357359 }
358360 } catch ( err ) {
359- loggingFunction ( `/!\\ Error from cart setter: ${ err . message } ` ) ;
361+ loggingFunction ( `/!\\ Error from cart setter: { ${ err . message } }` ) ;
360362 }
361363
362364 __META_LAYER_META_DATA . _order = newOrder ;
363365 }
364366 } ) ;
365367
366368 if ( settings . autoReloadInterval . value >= 10000 ) {
367- loggingFunction ( `Queued page auto-reload interval for ${ settings . autoReloadInterval . value } milliseconds` ) ;
369+ loggingFunction ( `Queued page auto-reload interval for { ${ settings . autoReloadInterval . value } } milliseconds` ) ;
368370
369371 setTimeout ( function ( ) { location . reload ( ) } , settings . autoReloadInterval . value ) ;
370372 } else {
0 commit comments