function extractTextFromPage() {
try {
const removeSelectors = [
"nav", "footer", "header", "script", "style", "noscript", "svg", "img[src^='data:']",
"[role='alert']", "[role='banner']", "[role='dialog']", "[role='alertdialog']",
"[role='region'][aria-label*='skip' i]", "[aria-modal='true']"
];
removeSelectors.forEach(selector => {
document.querySelectorAll(selector).forEach(el => el.remove());
});
const bodyText = document.body.innerText.replace(/\n+/g, ' ').trim();
console.log("===== EXTRAHIERTER TEXT =====\n", bodyText);
return bodyText; // Direkte Rückgabe an Keyboard Maestro
} catch (error) {
console.error("Fehler beim Extrahieren des Textes:", error);
return "Fehler beim Extrahieren des Textes.";
}
}
// Funktion aufrufen (für Keyboard Maestro)
extractTextFromPage();
Hey guys,
i used this code to extract the text from a website and id like to display or save the Results in a Variable. When i use "Display Results in a window" nothing will be displayed even though the results can be seen in the console. Can anyone help?