Fix identifier extraction for external sites on Twitter

This commit is contained in:
shinigami-eyes 2020-12-26 06:56:15 +00:00
parent 194dd1fb5f
commit f1b18eead3

View File

@ -422,8 +422,10 @@ function getIdentifierFromElementImpl(element: HTMLAnchorElement, originalTarget
if (title && (title.startsWith('http://') || title.startsWith('https://'))) if (title && (title.startsWith('http://') || title.startsWith('https://')))
return getIdentifier(title); return getIdentifier(title);
const content = element.textContent; const content = element.textContent;
if (!content.includes(' ') && content.includes('.') && !content.includes('…')) if (!content.includes(' ') && content.includes('.') && !content.includes('…')) {
return getIdentifier('http://' + content); const url = content.startsWith('http://') || content.startsWith('https://') ? content : 'http://' + content;
return getIdentifier(url);
}
} }
} else if (domainIs(hostname, 'wikipedia.org')) { } else if (domainIs(hostname, 'wikipedia.org')) {
if (element.classList.contains('interlanguage-link-target')) return null; if (element.classList.contains('interlanguage-link-target')) return null;