Add some extra error handling
This commit is contained in:
parent
eecc70d89b
commit
3bde6af554
8
index.js
8
index.js
@ -275,7 +275,9 @@ async function sendPage(website, tries = 0) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
document.body.innerHTML = `<h1>${document.getElementById('page-title').innerHTML}</h1>` + document.getElementById('page-content').innerHTML;
|
document.body.innerHTML = `<h1>${document.getElementById('page-title').innerHTML}</h1>` + document.getElementById('page-content').innerHTML;
|
||||||
} else if (isProbablyReaderable(document.cloneNode(true))) {
|
} else {
|
||||||
|
try {
|
||||||
|
if (isProbablyReaderable(document.cloneNode(true))) {
|
||||||
var documentClone = document.cloneNode(true);
|
var documentClone = document.cloneNode(true);
|
||||||
var article = new Readability(documentClone).parse();
|
var article = new Readability(documentClone).parse();
|
||||||
var postedDate = document.querySelector('time[datetime]');
|
var postedDate = document.querySelector('time[datetime]');
|
||||||
@ -288,6 +290,10 @@ async function sendPage(website, tries = 0) {
|
|||||||
` + article.content;
|
` + article.content;
|
||||||
document.body.innerHTML = content;
|
document.body.innerHTML = content;
|
||||||
}
|
}
|
||||||
|
} catch (ex) {
|
||||||
|
console.log("Failed to detect if readable")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[...document.querySelectorAll('details')].forEach(details => details.setAttribute('open', ''));
|
[...document.querySelectorAll('details')].forEach(details => details.setAttribute('open', ''));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user