Tampermonkey (userscript), JQuery & Vinted, aide !

Good evening,

I've been stuck for a few days on a script that I'm trying to run on Vinted article pages, such as https://www.vinted.fr/items/3455924924-tee-shirt-nike-xs.

I would like to retrieve the value of the shipping fees contained in the <h3> element with the attribute: data-testid='item-shipping-banner-price'

So far, I have this little piece of code, which seems to find the h3 in question but returns undefined when I try to print its innerHTML, its .html() or its .text():

$(document).ready(function() { var pathname = window.location.pathname; if ( pathname.startsWith("/items/")) { window.addEventListener('load', function () { var isb = $("[data-testid='item-shipping-banner-price']"); alert(isb.html()); }) } });

A little help would be welcome...
Thank you! ;)


Don't forget to mark the discussion as resolved as soon as it's done! -> At the top of the page, Status: Resolved
Also, be sure to respect the 6th rule of the charter: <code>Write messages in clear language without abbreviations, telegram style or SMS mode</code>

1 answer

  1. Moderator

    Hello

    Could you Run the following command in your code and show us what it says

    console.log($(["data-testid='item-shipping-banner-price'"]));

    .
    Best regards,
    Jordane

    0
    1. Here's what I have:

      1.  ce.fn.init ["data-testid='item-shipping-banner-price'"] 0: "data-testid='item-shipping-banner-price'" length: 1
      0
    2. Moderator
      @zzzer

      As you can see, it returns a stop with a single value.

      So you need to target the first value

      Using a [0]

      0