This commit is contained in:
xaoxuu 2022-10-26 23:10:59 +08:00
parent d3c4f4eb83
commit 8045326a85
1 changed files with 9 additions and 5 deletions

View File

@ -31,8 +31,9 @@ function renderer(el, obj) {
if (obj.icon && obj.icon.length > 0) {
el.querySelector('.img').style = 'background-image: url("' + obj.icon + '");';
}
if (obj.desc && obj.desc.length > 0) {
el.querySelector('.desc').innerHTML = obj.desc;
let desc = el.querySelector('.desc');
if (desc && obj.desc && obj.desc.length > 0) {
desc.innerHTML = obj.desc;
}
}
@ -53,9 +54,12 @@ function getInfo(el, html, link) {
title = title.textContent
// Get the src of the first img tag in the body tag
// icon = doc.querySelector('body img')
// icon = icon && icon.getAttribute('src')
let tmp = doc.querySelector('head link[rel="apple-touch-icon"]')
if (!tmp) {
tmp = doc.querySelector('head link[rel="icon"]')
}
icon = tmp && tmp.getAttribute('href')
if (/^data:image/.test(icon)) icon = ''
// If there is no src then get the site icon