-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
27 lines (23 loc) · 1009 Bytes
/
main.js
File metadata and controls
27 lines (23 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const form = document.getElementById('download-form');
const urlInput = document.getElementById('url-input');
const button = document.getElementById('download-button');
const cleanedHtmlContainer = document.getElementById('cleaned-html');
const errorMessage = document.getElementById('error-message');
form.addEventListener('submit', (event) => {
event.preventDefault();
const url = urlInput.value;
fetch(url)
.then(response => response.text())
.then(html => {
const cleanedHtml = html.replace(/filter:\s*blur\(\d+px\)\s*!important;/g, '');
const answer = cleanedHtml.match(/<article[^>]*>[\s\S]*<\/article>/g);
const cleanedHtmlElement = document.createElement('div');
cleanedHtmlElement.innerHTML = answer;
cleanedHtmlContainer.appendChild(cleanedHtmlElement);
errorMessage.style.display = 'none';
})
.catch(error => {
errorMessage.textContent = 'Verifique a URL e tente novamente';
errorMessage.style.display = 'block';
});
});