0

enter image description herei have a chrome extension that uses information from ebay website. now i want to update tracking numbers using the extension, but when ever i open the document where i want to update the tracking of an order all the elements there are hidden and i can't access anything, is this something ebay does on purpose to avoid us from having access there? or is it just something that i can overcome? added the function that get the doc page:

   var carrier = "USPS";
   let TrackCollection = new Map();  
   var allLines = trackingTxt.split("\n");
   for (var i=0;i< allLines.length;i++)
    {
        var splitLine = allLines[i].split("\t");
       if (splitLine.length == 2)
       {
         TrackCollection.set(splitLine[0],splitLine[1]);
       }
    }

    for (var j=0; j<elOrders.length; j++)
    { 
      if(elOrders[j].getAttribute("class").startsWith("order-info"))
      {
       var orderNum = elOrders[j].getElementsByClassName("order-details")[0].innerText;
       if (orderNum)//not null
        {
          trackingNumber = TrackCollection.get(orderNum);  
          if(trackingNumber)//not null
            {
                var par = elOrders[j+1].getElementsByClassName("item-tracking"); 
                doc = getDocPage(par[0].getElementsByTagName("a")[0].getAttribute("href"));
var textBox = doc.getElementsByClassName("textbox textbox--small");
                textBox[0].value = trackingNumber;
                textBox[1].value = carrier;
    .
    .
    .
function getDocPage(href)
{ 
   var xmlHttp = new XMLHttpRequest();
   xmlHttp.open("GET", href, false); // false = the request is  synchronous
   xmlHttp.send(null);
   var doc = new DOMParser().parseFromString(xmlHttp.responseText, 'text/html');
}

Thank you

Kobi
  • 117
  • 2
  • 12
  • The posted fragment of code is insufficient to diagnose the problem. I doubt ebay is doing something. The most likely reason your code is incorrect or it's running too early in which case setTimeout, setInterval, or MutationObserver may help, see also [Is there a JavaScript / jQuery DOM change listener?](https://stackoverflow.com/a/39508954) – wOxxOm May 28 '20 at 17:25
  • Thanks for your naswer, i added a bigger fragment of the code in the main thread, hope this helps, After "doc = getDocPage...." the doc visibiltyState is hidden and i can't access any element from there. – Kobi May 28 '20 at 19:58
  • Those elements are added by the site's scripts when the site is opened in a tab or in iframe. Scripts don't run when you download the page via `fetch` or `XMLHttpRequest`. The only way to get the info is to 1) use ebay's API, 2) find that info inside some ` – wOxxOm May 29 '20 at 05:33
  • what do you mean by find the info inside some – Kobi May 29 '20 at 19:50
  • You shouldn't run them. You can extract the info from their textContent using the standard string/regexp methods and JSON.parse for json. – wOxxOm May 30 '20 at 04:26

0 Answers0