- code: |-
// Function to extract all URLs from the page
function extractUrls() {
const urls = [];
// Select all anchor (a) elements on the page
const anchorElements = document.querySelectorAll('a');
// Iterate through each anchor element and extract the full URL
anchorElements.forEach(function (anchor) {
const url = anchor.href; // Use anchor.href to get the full URL
// Check if the URL is not null and not empty
if (url && url.trim() !== '') {
urls.push(url);
}
});
// Return the list of URLs as a string with each item separated by new lines
return urls.join('\n');
}
// Function to check if the DOM content has already loaded
function isDOMLoaded() {
return document.readyState === 'complete' || document.readyState === 'interactive';
}
// Check if the DOM content is already loaded
if (isDOMLoaded()) {
// If already loaded, immediately call extractUrls
const urlList = extractUrls();
console.log(urlList);
} else {
// If not loaded, wait for the DOMContentLoaded event
document.addEventListener('DOMContentLoaded', function () {
const urlList = extractUrls();
console.log(urlList);
// You can use the urlList variable as needed in your application
});
}
urlList = extractUrls();
return urlList;
type: js
args: ''
param: links
- message: '{{links}}'
type: say
All rights reserved © HARPA AI TECHNOLOGIES LLC, 2021 — 2024
Designed and engineered in Finland 🇫🇮