document.querySelector con AppleScript / Safari

Necesito un script para abrir cada pestaña en Safari cuando obtengo "valueIneed" de un sitio web interno

aquí está la etiqueta HTML

<td class="orderDetails">


    <p class="details">
        (My Certificate)
    </p>

esto es lo que intenté esto pero esto está fallando

tell application "Safari"
    do JavaScript "
        var forgiveStatus = document.querySelector('class[details\"(My Certificate).innerHTML;
        " in current tab of first window
    set checkvalue to (do JavaScript "theStatus;" in current tab of first window) as string
end tell

para obtener más información, podría tener varias instancias de la misma etiqueta, y necesito abrir cada una en una nueva pestaña, o mejor aún, hacer clic en ellas una tras otra

hay algo extraño con querySelectorla función. Me parece que falta el soporte de cierre allí. Estos son ejemplos del uso adecuado: developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
En ese caso, para obtener el valor del <p class="details">necesita llamardocument.querySelector(".details").innerHTML

Respuestas (2)

No ha cerrado ninguna comilla ni paréntesis. Necesita los siguientes cuatro caracteres.

var theStatus = document.querySelector('class[details="(valueIneed)"]')
                                                                   ^^^^

Esto ahora es JavaScript sintácticamente correcto. Todavía dudo que haga lo que necesita, pero sin ver el DOM de la página en la que está ejecutando esto y una descripción completa del problema, no puedo decirlo con certeza.

Dada la actualización de su pregunta con un fragmento de HTML, el código que está intentando no funcionará. Para obtener el HTML interno del elemento, use el siguiente JavaScript:

document.querySelector("td.orderDetails .details").innerHTML;
Gracias, probé esto pero siempre tengo un error de sintaxis "Se esperaba el final de la línea pero encontré "(".
@Kevin Entonces algo más está muy mal. Gracias por actualizar su pregunta, vea editar. ¡Tenga en cuenta que esto es Ask Different, no Stack Overflow!
property tmp : "~/Desktop/safarihtml.html"

set htmls to {}

tell application "Safari" to tell window 1 to if exists then ¬
    set htmls to do JavaScript ¬
        "Array.from(document" & ¬
        "          .getElementsByClassName('details'))" & ¬
        "     .map(x=>x.innerHTML);" in current tab

repeat with html in htmls
    newTabWithHTML(html)
end repeat

on newTabWithHTML(html)
    local html

    set furl to URL of tmpfile()

    set eof of (tmpfile() as alias) to 0
    write html to (tmpfile() as alias) as «class utf8»

    tell application "Safari" to tell ¬
        (a reference to window 1)
        if not (exists) then make new document

        set current tab to make new ¬
            tab with properties ¬
            {URL:furl}

        repeat until name of current tab ¬"Untitled"
            delay 1
        end repeat
    end tell

    delete tmpfile()
end newTabWithHTML


on tmpfile()
    tell application "System Events"
        set f to a reference to the file tmp
        if not (exists f) then (make new file ¬
            with properties {name:tmp})

        return f
    end tell
end tmpfile