function fetchAndExtractHTML(link, overwrite) { // Fetch the HTML content from the link fetch(link) .then(response => response.text()) .then(htmlContent => { // Create a temporary div element var tempDiv = document.createElement('div'); // Set the innerHTML of the temporary div with the fetched HTML content tempDiv.innerHTML = htmlContent; // Find all elements with the class "quoteheader" var quoteHeaderElements = tempDiv.querySelectorAll('.quoteheader'); // Loop through each quoteheader element quoteHeaderElements.forEach(function(element) { // Insert extra content before removing the element element.insertAdjacentHTML('beforebegin', '<div style="height: 15px;"></div>'); // Remove the element element.remove(); }); // Find the specific div element with class "inner" var targetDiv = tempDiv.querySelector('.inner'); if (targetDiv) { // Get the HTML content of the target div var extractedHTML = targetDiv.innerHTML; // Get the element where you want to apply the extracted HTML content var element = document.getElementById("maincontent"); // Set the innerHTML property to the extracted HTML content if (overwrite === true) { element.innerHTML = extractedHTML; } else { element.innerHTML += extractedHTML; } } else { console.log('No div element with class "inner" found.'); } }) .catch(error => console.log('Error fetching HTML:', error)); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)