问题
i have a website login: cyclefreight1@usa.com pas: 12345678, log in and go to the drivers section(left menu bar firs item > drivers) I want to make some additional function to this web with tampermonkey, i try to get all elements from the table, i do it with selector like this
var rows = document.querySelectorAll("#app table.table-component tr");
but all i have is undefined ^( , please give me some tips how can i do it, thank you
回答1:
The table is inside an iframe
on another domain, so it's tricky to access. Include the userscript on that other domain, and give it a setTimeout
to give the table time to populate:
// ==UserScript==
// @name drivers
// @match https://eldclient.trackingmap.eu/drivers*
// @grant none
// ==/UserScript==
setTimeout(() => {
const rows = document.querySelectorAll("#app table.table-component tr");
console.log(rows);
}, 2000);
来源:https://stackoverflow.com/questions/50327158/want-to-get-all-elements-from-the-table