How to display some additional data by injecting javascript with browser extension

时间:2019-05-16 09:33:49

标签: javascript html

I have a loop and I want to display a result. I cant write a line that work, please just give me some help with that the line below doesnt work

products.innerHTML = products.innerHTML + '<p> <script type="text/javascript"> document.write(eval('result')) </script> </p>'); 

    // All Products:
    var products = document.querySelectorAll("#orderTable > tbody > tr > td:nth-child(6)")
    for (product of products) {
      //Produkty:
      var step1 = product.innerHTML
      var step2 = step1.slice(0, 17);
      var step3 = step2.replace(/[^\d.-]/g, '');
      var step4 = parseFloat(step3)

      //Rabat:
      var krok1 = step1.search("Rabat: ");
      var krok2 = step1.slice(krok1 + 7, krok1 + 13 );
      var krok3 = krok2.replace(/[^\d.-]/g, '');
      var krok4 = parseFloat(krok3)

      //Result:
      var result = step4-krok4
      // I want to output result to the HTML here
    }

enter image description here enter image description here enter image description here

0 个答案:

没有答案