### Nav start logging Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-history-2018-0.html Logs the navigation start time if the navbar skeleton is not present. ```javascript if(!document.getElementById("navbar-skeleton")) { window.uet && uet('ns'); } ``` -------------------------------- ### Start timer with uet Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-history-egift.html Starts a timer using the uet function with the 'bb' event and the full timer name. Logs any errors. ```javascript startTimer:function(e){if(u(window))try{window.uet("bb",this.getFullTimerName(e),{wb:1})}catch(t){this.log(t,{message:"startTimer"})}} ``` -------------------------------- ### Start Rufus initial loading with QIS Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-details-112-4482432-2955442.html Starts the initial streaming request in the thick client by logging latency and count metrics, triggering the Rufus CX on initial loading, and executing a callback when the 'rufus-stream' promise resolves. ```javascript const startRufusInitialLoadingWithQis = featureScope.startRufusInitialLoading + ":" + streamParams.qis; logLatency(startRufusInitialLoadingWithQis, true); logCount(startRufusInitialLoadingWithQis); triggerRufusCXOnInitialLoading(streamParams); extendedWindow.P && extendedWindow.P.when("rufus-stream").execute(() => { logLatency(startRufusInitialLoadingWithQis, false); }); ``` -------------------------------- ### Content Rendering Plugin Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-history-2024-0.html Initializes configuration and setup for tracking content rendering and mutations. ```javascript csa.plugin(function(u){var i,t="Content",e="MutationObserver",n="addedNodes",a="querySelectorAll",f="matches",r="getAttributeNames",o="getAttribute",s="dataset",c="widget",l="producerId",d="slotId",h="iSlotId",g={ent:{element:1,page:["pageType","subPageType","requestId"]}},p=5,m=u.config[t+".BubbleUp.SearchDepth"]||35,y=u.config[t+".SearchPage"]||0,v="csaC",b=v+"Id",E="logRender",w={},I=u.config,O=I[t+".Selectors"]||[],C=I[t+".WhitelistedAttributes"]||{href:1,class:1},N=I[t+".EnableContentEntities"],S=I["KillSwitch.ContentRendered"],k=u.global,A=k.document||{},U=A.documentElement,L=k.HTMLElement,R={},_=[],j=function(t,e,n,i){var ``` -------------------------------- ### Push NavMainStart event Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/auth/unauth-index.html Pushes a NavMainStart event to navmet if ue_t0 is available, recording the main navigation start time. ```javascript if (window.ue\_t0) { window.navmet.push({key:"NavMainStart",end:+new Date(),begin:window.ue\_t0}); } ``` -------------------------------- ### Record page start time Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/auth/acic-challenge.html Records the page start time in milliseconds since the Unix epoch. Used for performance tracking on the challenge page. ```javascript var aPageStart = (new Date()).getTime(); ``` -------------------------------- ### Start Rufus initial streaming request with QIS Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-details-112-5939971-8962610.html Starts the initial streaming request in the thick client by logging latency and count metrics, triggering the Rufus CX on initial loading, and executing a callback when the 'rufus-stream' promise resolves. ```javascript const startRufusInitialLoadingWithQis = featureScope.startRufusInitialLoading + ":" + streamParams.qis; logLatency(startRufusInitialLoadingWithQis, true); logCount(startRufusInitialLoadingWithQis); triggerRufusCXOnInitialLoading(streamParams); extendedWindow.P && extendedWindow.P.when("rufus-stream").execute(() => { logLatency(startRufusInitialLoadingWithQis, false); }); ``` -------------------------------- ### SafeFrame Metrics Initialization Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-history-2024-0.html Starts CSM and CSA metrics for the specified placement. ```javascript window.grandprix.metrics.startSafeFrameCSMMetrics("ape_YourOrders_desktop-yo-footer-1_desktop_placement"); window.grandprix.metrics.startSafeFrameCSAMetrics("ape_YourOrders_desktop-yo-footer-1_desktop_placement"); ``` -------------------------------- ### Initialize navmet and record basic metrics Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/auth/unauth-index.html Initializes window.navmet if undefined, and if performance timing and ue_t0 are available, records basic navigation metrics like network latency, first paint, and navigation start. It also pushes a NavFirstPaintStart event. ```javascript if(window.navmet===undefined) { window.navmet=\[" ]; if (window.performance && window.performance.timing && window.ue\_t0) { var t = window.performance.timing; var now = + new Date(); window.navmet.basic = { 'networkLatency': (t.responseStart - t.fetchStart), 'navFirstPaint': (now - t.responseStart), 'NavStart': (now - window.ue\_t0) }; window.navmet.push({key:"NavFirstPaintStart",end:+new Date(),begin:window.ue\_t0}); } } ``` -------------------------------- ### Cookie Set, Get, and Delete Functions Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-history-wholefoods.html These functions manage cookies by setting, getting, and deleting them. The get function counts duplicate cookies and updates a counter if more than one is found. The delete function sets an expired cookie. ```javascript t.cookieSet=function(e,t,n){o(e);var r=new Date;r.setTime(r.getTime()+24*n*60*60*1e3);var i="expires="+r.toUTCString();document.cookie=e+"="+t+"; "+i+A} ``` ```javascript t.cookieGet=function(e){for(var t=e+"=",n="",A=0,o=document.cookie.split(";"),i=0;i1&&r.updateCounter("Siege:Csd:DuplicateCookieDetected",1);return n} ``` ```javascript t.cookieDelete=o;var r=new(n(28).Logger),A="; path=/"+("https:"===window.location.protocol?"; secure":"");function o(e){document.cookie=e+"=; expires=Thu, 01 Jan 1970 00:00:01 GMT"+A,document.cookie=e+"=; expires=Thu, 01 Jan 1970 00:00:01 GMT; domain="+location.hostname+A} ``` -------------------------------- ### Search Initialization and Autocomplete Setup Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-details-fopo-113-4055495-4107437.html Initializes the search CSL and creates the autocomplete instance. Includes functions for building the ISS init object and logging metrics. ```JavaScript searchCSL.init( opts.pageType, (window.ue && window.ue.rid) || opts.requestId ); $SearchJS.declare("canCreateAutocomplete", issInitObject); } // END initSearchCsl function createAutocomplete(issObject) { iss = new AutoComplete(issObject); $SearchJS.publish("search-js-autocomplete", iss); logMetrics(); } // END createAutocomplete function buildIssInitObject(opts, issOpts, isNewIss) { var issInitObj = { src: opts.host , sessionId: opts.sessionId , requestId: opts.requestId , mkt: opts.marketId , obfMkt: opts.obfuscatedMarketId , pageType: opts.pageType , language: opts.language , customerId: opts.customerId , fresh: opts.fresh , b2b: opts.b2b , aliases: opts.searchAliases , fb: issOpts.fallbackFlag , isDigitalFeaturesEnabled: issOpts.isDigitalFeaturesEnabled , isWayfindingEnabled: issOpts.isWayfindingEnabled , issPrimeEligible: issOpts.issPrimeEligible , deptText: issOpts.departmentText , sugText: issOpts.suggestionText , filterAliases: opts.filterAliases , biaWidgetUrl: opts.biaWidgetUrl , recentSearchesTreatment: issOpts.recentSearchesTreatment , authorSuggestionText: issOpts.authorSuggestionText , translatedStringsMap: issOpts.translatedStringsMap , biaTitleText: "" , biaPurchasedText: "" , biaViewAllText: "" , biaViewAllManageText: "" , biaAndText: "" , biaManageText: "" , biaWeblabTreatment: "" , issNavConfig: issOpts.issNavConfig , cf: issOpts.cf , ime: opts.isJpOrCn , mktid: opts.marketId , qs: opts.isJpOrCn , issCorpus: issOpts.issCorpus , deepNodeISS: { searchAliasAccessor: function($) { return (window.SearchPageAccess && window.SearchPageAccess.searchAlias()) || $('select.searchSelect').children().attr('data-root-alias'); }, searchAliasDisplayNameAccessor: function() { return (window.SearchPageAccess && window.SearchPageAccess.searchAliasDisplayName()); } } , removeDeepNodeISS: issOpts.removeDeepNodeISS , trendingTreatment: issOpts.trendingTreatment , useAPIV2: issOpts.useAPIV2 , opfSwitch: issOpts.opfSwitch , isISSDesktopRefactorEnabled: issOpts.isISSDesktopRefactorEnabled , useServiceHighlighting: issOpts.useServiceHighlighting , isInternal: issOpts.isInternal , isAPICachingDisabled: issOpts.isAPICachingDisabled , isBrowseNodeScopingEnabled: issOpts.isBrowseNodeScopingEnabled , isStorefrontTemplateEnabled: issOpts.isStorefrontTemplateEnabled , disableAutocompleteOnFocus: issOpts.disableAutocompleteOnFocus , asin: opts.asin }; // If we aren't using the new ISS then we need to add these properties if (!isNewIss) { issInitObj.dd = issOpts.dropdown; // The element with id searchDropdownBox doesn't exist in C. issInitObj.imeSpacing = issOpts.imeSpacing; issInitObj.isNavInline = 1; issInitObj.triggerISSOnClick = 0; issInitObj.sc = 1; issInitObj.np = issOpts.np; } return issInitObj; } // END buildIssInitObject function logMetrics() { if (typeof uet == 'function' && typeof uex == 'function') { uet('be', 'iss-init-pc', { wb: 1 }); uex('ld', 'iss-init-pc', { wb: 1 }); } } // END logMetrics ``` -------------------------------- ### Initialize timing and build date Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-details-112-9087159-1657009.html Sets up strict mode, timing functions, and initializes the build date constant. ```javascript "use strict";var t=C.now=C.now||function(){return+new C},r=function(a){return a&&a.now?a.now.bind(a):t}(g.performance),ia=r(),ha={},n=g.ue;E();E("aui_build_date:3.24.9-2024-10-31"); ``` -------------------------------- ### Install amazon-orders via pip Source: https://github.com/alexdlaird/amazon-orders/blob/develop/docs/index.rst Install or upgrade the library using pip. ```sh pip install amazon-orders --upgrade ``` -------------------------------- ### Initialize Buy It Again widget in Your Account side panel Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-history-egift.html Initializes the Buy It Again widget in the Your Account side panel. It checks config.disableBuyItAgain, registers a render callback, truncates the flyout to fit recommendations, and fetches data from /gp/bia/external/bia-hcb-ajax-handler.html with a 4-second timeout. The widget is only shown if data.dramResult is present. ```javascript (function ($Nav) { "use strict"; if (typeof $Nav === 'undefined' || $Nav === null || typeof $Nav.when !== 'function') { return; } $Nav.when('$', 'data', 'flyout.yourAccount', 'sidepanel.csYourAccount', 'config') .run("BuyitAgain-YourAccount-SidePanel", function ($, data, yaFlyout, csYourAccount, config) { if (config.disableBuyItAgain) { return; } var render = function (data) { if (data.dramResult) { var widgetHtml = data.dramResult; navbar.sidePanel({ flyoutName: 'yourAccount', data: {html: widgetHtml} }); } }; var renderBuyItAgain = function (biaData) { if (csYourAccount) { csYourAccount.register(render, biaData); } else { render(biaData); } }; var truncateAndRestructureYaFlyout = function() { if (window.P) { P.when('A', 'a-truncate').execute(function(A, truncate) { var truncateElements = A.$('.a-truncate'); A.each(truncateElements, function(element) { truncate.get(element).update(); }); var recommendationsWidget = document.getElementById('bia-hcb-widget'); if (recommendationsWidget) { var navFlyout = recommendationsWidget.parentElement; var navFlyoutPaddingBottom = parseInt(window.getComputedStyle(navFlyout).getPropertyValue('padding-bottom')); var navFlyoutContentHeight = navFlyout.clientHeight - navFlyoutPaddingBottom; while (recommendationsWidget.offsetHeight > navFlyoutContentHeight && recommendationsWidget.offsetHeight > 0){ var recommendations = recommendationsWidget.querySelectorAll('.biaNavFlyoutFaceout'); if (recommendations.length <= 1) { break; } var lastRecommendation = recommendations[recommendations.length - 1]; lastRecommendation.parentElement.removeChild(lastRecommendation); } } }); } }; yaFlyout.sidePanel.onData(truncateAndRestructureYaFlyout); yaFlyout.onShow(truncateAndRestructureYaFlyout); yaFlyout.onRender(function() { $.ajax({ url: '/gp/bia/external/bia-hcb-ajax-handler.html', data: {"biaHcbRid":"P0YNVMGHJ6AZR954997D"}, dataType: 'json', timeout: 4*1000, success: renderBuyItAgain, error: function (jqXHR, textStatus, errorThrown) { } }); }); }); })(window.$Nav); ``` -------------------------------- ### Minified JavaScript for Siege CSD LocalStorage and Bootstrap Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-details-fopo-147-7999693-6862434.html This minified JavaScript code defines a LocalStorage class for managing keys prefixed with 'SIEGE_CSD_'. It includes methods to put, get, remove, and clear entries, with support for tracking last used dates. The code also includes a bootstrap function that checks if the CSD is installed, rotates keys if needed, and updates counters. It uses the regenerator runtime for async/await and is part of a larger module bundle. ```JavaScript class as a function"})}(this,e),c(this,"logger",new r.Logger),c(this,"encoder",new A.Encoder)}var t,n,i,s,f;return t=e,(n=[{key:"put",value:function(e,t){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:new Date;localStorage.setItem("SIEGE_CSD_"+e,JSON.stringify({key:this.encoder.encode(t),issuedDate:n}))}},{key:"getAll",value:function(){var e=new Map,t=!0,n=!1,r=undefined;try{for(var A,o=this.getAllKeys()[Symbol.iterator]();!(t=(A=o.next()).done);t=!0){var i=A.value;e.set(i,this.get(i,!1))}}catch(err){n=!0,r=err}finally{try{t||null==o["return"]||o["return"]()}finally{if(n)throw r}}return e}},{key:"get",value:function(e){var t=!(arguments.length>1&&arguments[1]!==undefined)||arguments[1],n=localStorage.getItem("SIEGE_CSD_"+e);if(null===n)return undefined;var r=new Date,A=JSON.parse(n);return(t||A.lastUsedDate===undefined)&&localStorage.setItem("SIEGE_CSD_"+e,JSON.stringify(a({},A,{lastUsedDate:r}))),{key:this.encoder.decode(A.key),issuedDate:new Date(A.issuedDate),lastUsedDate:A.lastUsedDate!==undefined?new Date(A.lastUsedDate):r}}},{key:"removeKeys",value:function(e){var t=!0,n=!1,r=undefined;try{for(var A,o=e[Symbol.iterator]();!(t=(A=o.next()).done);t=!0){var i=A.value;localStorage.removeItem("SIEGE_CSD_"+i)}}catch(err){n=!0,r=err}finally{try{t||null==o["return"]||o["return"]()}finally{if(n)throw r}}}},{key:"getAllKeys",value:function(){for(var e=[],t=0;t0&&n[0]!==undefined&&n[0],e.next=3,c["delete"](t);case 3:return e.next=5,p();case 5:if(!e.sent){e.next=7;break}throw new Error("csdIsInstalled still returned true after uninstall");case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function p(){return y.apply(this,arguments)}function ``` -------------------------------- ### Initialize Buy it Again widget in Your Account side panel Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-history-2018-0.html Initializes the Buy it Again widget in the Your Account side panel. It fetches recommendations via AJAX, renders them, and truncates the flyout if the widget overflows. ```javascript (function ($Nav) { "use strict"; if (typeof $Nav === 'undefined' || $Nav === null || typeof $Nav.when !== 'function') { return; } $Nav.when('$', 'data', 'flyout.yourAccount', 'sidepanel.csYourAccount', 'config') .run("BuyitAgain-YourAccount-SidePanel", function ($, data, yaFlyout, csYourAccount, config) { if (config.disableBuyItAgain) { return; } var render = function (data) { if (data.dramResult) { var widgetHtml = data.dramResult; navbar.sidePanel({ flyoutName: 'yourAccount', data: {html: widgetHtml} }); } }; var renderBuyItAgain = function (biaData) { if (csYourAccount) { csYourAccount.register(render, biaData); } else { render(biaData); } }; var truncateAndRestructureYaFlyout = function() { if (window.P) { P.when('A', 'a-truncate').execute(function(A, truncate) { var truncateElements = A.$('.a-truncate'); A.each(truncateElements, function(element) { truncate.get(element).update(); }); var recommendationsWidget = document.getElementById('bia-hcb-widget'); if (recommendationsWidget) { var navFlyout = recommendationsWidget.parentElement; var navFlyoutPaddingBottom = parseInt(window.getComputedStyle(navFlyout).getPropertyValue('padding-bottom')); var navFlyoutContentHeight = navFlyout.clientHeight - navFlyoutPaddingBottom; while (recommendationsWidget.offsetHeight > navFlyoutContentHeight && recommendationsWidget.offsetHeight > 0){ var recommendations = recommendationsWidget.querySelectorAll('.biaNavFlyoutFaceout'); if (recommendations.length <= 1) { break; } var lastRecommendation = recommendations[recommendations.length - 1]; lastRecommendation.parentElement.removeChild(lastRecommendation); } } }); } }; yaFlyout.sidePanel.onData(truncateAndRestructureYaFlyout); yaFlyout.onShow(truncateAndRestructureYaFlyout); yaFlyout.onRender(function() { $.ajax({ url: '/gp/bia/external/bia-hcb-ajax-handler.html', data: {"biaHcbRid":"1GWPEVM3KVW6HHRRB6YY"}, dataType: 'json', timeout: 4*1000, success: renderBuyItAgain, error: function (jqXHR, textStatus, errorThrown) { } }); }); }); })(window.$Nav); ``` -------------------------------- ### Install WAF auto-solve extras Source: https://github.com/alexdlaird/amazon-orders/blob/develop/docs/index.rst Install third-party integrations to enable WAF auto-solve functionality. ```sh pip install amazon-orders[capsolver] pip install amazon-orders[anticaptcha] pip install amazon-orders[2captcha] ``` -------------------------------- ### Install legacy Captcha extra Source: https://github.com/alexdlaird/amazon-orders/blob/develop/docs/index.rst Install the captcha extra for legacy Captcha auto-solve on Python versions 3.12 and below. ```sh pip install amazon-orders[captcha] ``` -------------------------------- ### Initialize Buy it again widget Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-history-2024-0.html Initializes the 'Buy it again' widget using the Amazon client runtime and registers the card factory. ```javascript if(window.mix_csa){window.mix_csa('[cel_widget_id="p13n-desktop-list_desktop-yo-rightrails_0"]', '#CardInstancenV1wXgmyVaTNEXdOavLIBg')('mark', 'be')} if(window.uet){window.uet('be','p13n-desktop-list_desktop-yo-rightrails_0',{wb: 1})} if(window.mixTimeout){window.mixTimeout('p13n-desktop-list', 'CardInstancenV1wXgmyVaTNEXdOavLIBg', 90000)}; P.when('mix:@amzn/mix.client-runtime', 'mix:p13n-desktop-list__0NU9jLsz').execute(function (runtime, cardModule) {runtime.registerCardFactory('CardInstancenV1wXgmyVaTNEXdOavLIBg', cardModule).then(function(){if(window.mix_csa){window.mix_csa('[cel_widget_id="p13n-desktop-list_desktop-yo-rightrails_0"]', '#CardInstancenV1wXgmyVaTNEXdOavLIBg')('mark', 'functional')}if(window.uex){window.uex('ld','p13n-desktop-list_desktop-yo-rightrails_0',{wb: 1})}});}); P.load.js('https://images-na.ssl-images-amazon.com/images/I/31yvpwgGF6L.js?xcp'); ``` -------------------------------- ### Initialize renderingWeblabs with experiment flags Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-history-2020-50.html Initializes the window.renderingWeblabs object and merges a JSON object of experiment flags into it, preserving any existing flags. ```javascript window.renderingWeblabs = window.renderingWeblabs ? window.renderingWeblabs : {}; window.renderingWeblabs = Object.assign(window.renderingWeblabs, JSON.parse('{"ADPT\_SF\_ADSP\_VIDEO\_833419":"C","ADPT\_SF\_CLIENT\_LATENCY\_2023Q1\_632539":"C","ADPT\_SF\_CLIENT\_LATENCY\_2023Q3\_737747":"C","ADPT\_SF\_APE\_WW\_MOBILE\_SEARCH\_ZOETROPE\_EPB\_EXP\_792200":"T1","ADPT\_SF\_SPARKLE\_838607":"C","ADPT\_SF\_EXPANDABLE\_ADS\_716745":"C","ADPT\_SF\_CLIENT\_LATENCY\_2023Q3\_GATING\_805312":"C","ADPT\_SF\_ILM\_EWC\_764130":"T1","ADPT\_SF\_ARIA\_HIDDEN\_644521":"T1","ADPT\_SF\_DEALS\_REFACTOR\_820101":"C","ADPT\_SF\_JAVELIN\_BID\_PRESENT\_PUNTING\_747631":"T1","ADPT\_SF\_MRC\_RETEST\_643771":"T1","ADPT\_SF\_DOCWRITE\_689243":"T1","ADPT\_SF\_TRANSPARENCY\_INFO\_MANDATORY\_FOR\_EU\_712921":"C"}')); ``` -------------------------------- ### Send GET request with XMLHttpRequest Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-details-coupon-savings.html Sends an asynchronous GET request using XMLHttpRequest and logs an error on failure. The function calls itself recursively, which may be unintended. ```javascript function sendRequest() { const xhr = new XMLHttpRequest(); xhr.open('GET', '/some-endpoint', true); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { // handle success } else { const errorMessage = "Request failed. Status Code: " + xhr.status + ", Status text: " + xhr.statusText; logError(new Error(errorMessage)); } } }; xhr.send(); sendRequest(); return true; } ``` -------------------------------- ### Buy it again Your Account side panel logic Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-history-amazon-store.html Handles the 'Buy it again' widget in the Your Account side panel. It fetches recommendations via AJAX, renders them, and truncates the flyout to fit the available space. The code runs only if the 'Buy it again' feature is not disabled. ```javascript (function ($Nav) { "use strict"; if (typeof $Nav === 'undefined' || $Nav === null || typeof $Nav.when !== 'function') { return; } $Nav.when('$', 'data', 'flyout.yourAccount', 'sidepanel.csYourAccount', 'config') .run("BuyitAgain-YourAccount-SidePanel", function ($, data, yaFlyout, csYourAccount, config) { if (config.disableBuyItAgain) { return; } var render = function (data) { if (data.dramResult) { var widgetHtml = data.dramResult; navbar.sidePanel({ flyoutName: 'yourAccount', data: {html: widgetHtml} }); } }; var renderBuyItAgain = function (biaData) { if (csYourAccount) { csYourAccount.register(render, biaData); } else { render(biaData); } }; var truncateAndRestructureYaFlyout = function() { if (window.P) { P.when('A', 'a-truncate').execute(function(A, truncate) { var truncateElements = A.$('.a-truncate'); A.each(truncateElements, function(element) { truncate.get(element).update(); }); var recommendationsWidget = document.getElementById('bia-hcb-widget'); if (recommendationsWidget) { var navFlyout = recommendationsWidget.parentElement; var navFlyoutPaddingBottom = parseInt(window.getComputedStyle(navFlyout).getPropertyValue('padding-bottom')); var navFlyoutContentHeight = navFlyout.clientHeight - navFlyoutPaddingBottom; while (recommendationsWidget.offsetHeight > navFlyoutContentHeight && recommendationsWidget.offsetHeight > 0){ var recommendations = recommendationsWidget.querySelectorAll('.biaNavFlyoutFaceout'); if (recommendations.length <= 1) { break; } var lastRecommendation = recommendations[recommendations.length - 1]; lastRecommendation.parentElement.removeChild(lastRecommendation); } } }); } }; yaFlyout.sidePanel.onData(truncateAndRestructureYaFlyout); yaFlyout.onShow(truncateAndRestructureYaFlyout); yaFlyout.onRender(function() { $.ajax({ url: '/gp/bia/external/bia-hcb-ajax-handler.html', data: {"biaHcbRid":"39FF8HC5V6JDDSJQFGBS"}, dataType: 'json', timeout: 4*1000, success: renderBuyItAgain, error: function (jqXHR, textStatus, errorThrown) { } }); }); }); })(window.$Nav); ``` -------------------------------- ### Install amazon-orders with browser support Source: https://github.com/alexdlaird/amazon-orders/blob/develop/docs/browser.rst Install the package with the [browser] extra to enable headless browser functionality for handling JavaScript-based challenges. ```shell pip install amazon-orders[browser] ``` -------------------------------- ### Initialize Performance Monitoring and Widget Loading Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-history-2024-0.html This script sets up performance tracking and initializes widget loading for the page. ```javascript window.ue_ibe = (window.ue_ibe || 0) + 1; if (window.ue_ibe === 1) { (function(e,c){function h(b,a){f.push([b,a])}function g(b,a){if(b){var c=e.head||e.getElementsByTagName("head")[0]||e.documentElement,d=e.createElement("script");d.async="async";d.src=b;d.setAttribute("crossorigin","anonymous");a&&a.onerror&&(d.onerror=a.onerror);a&&a.onload&&(d.onload=a.onload);c.insertBefore(d,c.firstChild)}}function k(){ue.uels=g;for(var b=0;b div", "id_gen":function(elem, index){ return 'nav_sitewide_msg'; } } ]; ue.uels("https://images-na.ssl-images-amazon.com/images/I/31bJewCvY-L.js"); } var ue_mbl=ue_csm.ue.exec(function(h,a){function s(c){b=c||{};a.AMZNPerformance=b;b.transition=b.transition||{};b.timing=b.timing||{};if(a.csa){var d;b.timing.transitionStart&&(d=b.timing.transitionStart);b.timing.processStart&&(d=b.timing.processStart);d&&(csa("PageTiming")("mark","nativeTransitionStart",d),csa("PageTiming")("mark","transitionStart",d))}h.ue.exec(t,"csm-android-check")()&&b.tags instanceof Array&&(c=-1!=b.tags.indexOf("usesAppStartTime")||b.transition.type?!b.transition.type&&-1< b.tags.indexOf("usesAppStartTime")?"warm-start":void 0:"view-transition",c&&(b.transition.type=c));n=null;"reload"===e._nt&&h.ue_orct||"intrapage-transition"===e._nt?u(b):"undefined"===typeof e._nt&&f&&f.timing&&f.timing.navigationStart&&a.history&&"function"===typeof a.History&&"object"===typeof a.history&&a.history.length&&1!=a.history.length&&(b.timing.transitionStart=f.timing.navigationStart);p&&e.ssw(q,""+(b.timing.transitionStart||n||""));c=b.transition;d=e._nt?e._nt:void 0;c.subType=d;a.ue&& a.ue.tag&&a.ue.tag("has-AMZNPerformance");e.isl&&a.uex&&a.uex("at","csm-timing");v()}function w(c){a.ue&&a.ue.count&&a.ue.count("csm-cordova-plugin-failed",1)}function t(){return a.cordova&&a.cordova.platformId&&"android"==a.cordova.platformId}function u(){if(p){var c=e.ssw(q),a=function(){},x=e.count||a,a=e.tag||a,k=b.timing.transitionStart,g=c&&!c.e&&c.val;n=c=g?+c.val:null;k&&g&&k>c?(x("csm.jumpStart.mtsDiff",k-c||0),a("csm-rld-mts-gt")):k&&g?a("csm-rld-mts-leq"):g?k||a("csm-rld-mts-no-new"):a("csm-rld-mts-no-old")}f&& f.timing&&f.timing.navigationStart?b.timing.transitionStart=f.timing.navigationStart:delete b.timing.transitionStart}function v(){try{a.P.register("AMZNPerformance",function(){return b})}catch(c){}}function r(){if(!b)return"";ue_mbl.cnt=null;var c=b.timing,d=b.transition,d=["mts",l(c.transitionStart),"mps",l(c.processStart),"mtt",d.type,"mtst",d.subType,"mtlt",d.launchType];a.ue&&a.ue.tag&&(c.fr_ovr&&a.ue.tag("fr_ovr"),c.fcp_ovr&&a.ue.tag("fcp_ovr"),d.push("fr_ovr",l(c.fr_ovr),"fcp_ovr",l(c.fcp_ovr))); for(var c="",e=0;e1&&r.updateCounter("Siege:Csd:DuplicateCookieDetected",1);return n} ``` ```javascript t.cookieDelete=o;var r=new(n(28).Logger),A="; path="+("https:"===window.location.protocol?"; secure":"");function o(e){document.cookie=e+"=; expires=Thu, 01 Jan 1970 00:00:01 GMT"+A,document.cookie=e+"=; expires=Thu, 01 Jan 1970 00:00:01 GMT; domain="+location.hostname+A} ``` -------------------------------- ### Get species constructor Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-details-112-9087159-1657009.html This module exports a function that gets the species constructor from an object. It uses the constructor's Symbol.species property if available, otherwise returns a default value. ```javascript var r=n(9),A=n(41),o=n(2)("species");e.exports=function(e,t){var n,i=r(e).constructor;return i===undefined||(n=r(i)[o])==undefined?t:A(n)} ``` -------------------------------- ### Initialize rendering weblabs and lightAds for ad placement Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/auth/unauth-index.html Sets up the rendering weblabs configuration and initializes the lightAds object for the 'ape_Gateway_right-2_desktop_placement' ad slot. It assigns an empty object to the lightAdDetails property, likely to be populated later. ```javascript window.renderingWeblabs = {"ADPT\_SF\_HIGH\_RATE\_METRIC\_LOGGING\_1256364":"C","ADPT\_SF\_LIGHTADS\_REFACTOR\_903064":"T1","APM\_STORES\_JPS\_JRS\_SAFEFRAME\_DOCUMENT\_WRITE\_1286180":"C","APM\_STORES\_JPS\_JRS\_SAFEFRAME\_CONTINUOUS\_OBSTRUCTION\_CHECK\_1246149":"T1","A2I\_HOMEPAGE\_CARD\_THEMING\_360311":"T2","APM\_STORES\_JPS\_JRS\_SAFEFRAME\_DEDUPE\_SF\_VIDEO\_PIXELS\_1279569":"T1","ADPT\_SF\_LOW\_RATE\_METRIC\_LOGGING\_1256362":"C","APM\_STORES\_JPS\_JRS\_SAFEFRAME\_SIZING\_1238561":"T1","SAFEFRAME\_NEW\_PIXEL\_FIRING\_922534":"C","ADPT\_SF\_SPARKLE\_838607":"C","APM\_STORES\_JPS\_JRS\_SAFEFRAME\_OBSTRUCTIONS\_1237329":"T1","SPONSORED\_PRODUCTS\_1261506":"C","ADPT\_SF\_GWATF\_ROUNDED\_CORNERS\_1036948":"T1","APM\_STORES\_JPS\_JRS\_SAFEFRAME\_ONERROR\_COLLAPSE\_1285300":"T1","APM\_STORES\_JPS\_JRS\_SAFEFRAME\_REMOVE\_ALLOW\_SAME\_ORIGIN\_1210497":"T1","APM\_STORES\_JPS\_JRS\_SAFEFRAME\_SERVER\_SIDE\_CREATIVE\_SIZING\_1230792":"C","CJ\_GWM\_WD\_AUTOROTATE\_REC\_1249308":"C","ADPT\_LA\_SERVER\_SIDE\_EXCLUSIVE\_RENDERING\_1089618":"C"}; window.lightAds = window.lightAds || {}; window.lightAds['ape\_Gateway\_right-2\_desktop\_placement'] = {}; window.lightAds['ape\_Gateway\_right-2\_desktop\_placement'].lightAdDetails = ``` -------------------------------- ### Get prototype Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-details-112-9087159-1657009.html This module exports a function that gets the prototype of an object. It uses the native Object.getPrototypeOf if available, otherwise it falls back to checking the IE_PROTO property or the constructor's prototype. ```javascript var r=n(4),A=n(25),o=n(58),i=n(133),a=o("IE\_PROTO"),u=Object.prototype;e.exports=i?Object.getPrototypeOf:function(e){return e=A(e),r(e,a)?e[a]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?u:null} ``` -------------------------------- ### Rufus Configuration Initialization Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-history-2024-0.html Initializes the Rufus panel with specific configuration parameters, view context, and external client data. ```json ({"rufusPanelConfigString":"{\"panelWidth\":\"320px\",\"panelHeightRatio\":\"0.5\",\"minimizedPanelWidth\":\"240px\",\"peekViewPanelWidth\":\"320px\"}","rufusViewContext":{"pageType":"YourOrders"},"isCacheEnabled":true,"uniqueId":"c96a1af6ae9b425dfb76831cc4d37076efec1a7866d9e5f6a30f75031578a6f9","renderRequestForAllPageTypesEnabled":false,"isAutoMinimizeEnabled":true,"rufusErrorMessageText":"Something went wrong. Try again later.","latencyRegressionMitigationStrategy":"shouldDelayThickClientInitialization","rufusTriggerMarkerMappingString":"{\"Detail\":\"dp-latency-marker\",\"Search\":\"af\",\"Gateway\":\"af\",\"ShoppingCart\":\"cf\"}","rufusTriggerMarkerFallbackTimeoutString":"3000","externalClientsData":{"heroBanner":"{\"actions\":[{\"name\":\"HolidayShopRedirect\",\"type\":\"stream\",\"context\":{\"qis\":\"NileIngressLink\"}},{\"name\":\"GetStartedRedirect\",\"type\":\"stream\",\"context\":{\"qis\":\"NileIngressLink\"}}]}"}})); })() ``` -------------------------------- ### Get property names Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-details-112-9087159-1657009.html This code defines a function that returns the property names of an object. It uses a helper to get all property names, including non-enumerable ones, and falls back to a custom implementation if Object.getOwnPropertyNames is not available. ```javascript var r=n(82),A=n(60).concat("length","prototype");t.f=Object.getOwnPropertyNames||function(e){return r(e,A)} ``` -------------------------------- ### Initialize BTF grid with GwGridLogic Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/auth/unauth-index.html Executes BTF grid initialization after the 'GwGridLogic' module loads, firing performance tracking events and initializing the main content grid. ```javascript P.when('GwGridLogic').execute('BTFGridInit', function(g) { window.uet && uet('cf', 'gwBTFGridInit', {wb: 1}); window.uex && uex('ld', 'gwBTFGridInit', {wb: 1}); g('#main-content').init(); }); ``` -------------------------------- ### Log ISS initialization metrics Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/transactions/transactions-refunded.html Logs metrics for ISS initialization using uet and uex functions if they are available. It sends 'be' and 'ld' events with the label 'iss-init-pc'. ```javascript function logMetrics() { if (typeof uet == 'function' && typeof uex == 'function') { uet('be', 'iss-init-pc', { wb: 1 }); uex('ld', 'iss-init-pc', { wb: 1 }); } } // END logMetrics ``` -------------------------------- ### Get own property descriptor Source: https://github.com/alexdlaird/amazon-orders/blob/develop/tests/resources/orders/order-details-112-9087159-1657009.html This code defines a module that exports a function to get an own property descriptor. It uses several internal dependencies and falls back to a custom implementation if the native Object.getOwnPropertyDescriptor is not available. This is part of a polyfill or utility library. ```javascript var r=n(8),A=n(76),o=n(29),i=n(35),a=n(36),u=n(4),c=n(77),s=Object.getOwnPropertyDescriptor;t.f=r?s:function(e,t){if(e=i(e),t=a(t,!0),c)try{return s(e,t)}catch(n){}if(u(e,t))return o(!A.f.call(e,t),e[t])} ```