Detection of external links in new Twitter UI

This commit is contained in:
shinigami-eyes 2019-07-28 07:31:04 +02:00
parent 960cc6d3a4
commit 1ce13a27d7
2 changed files with 11 additions and 1 deletions

View File

@ -374,6 +374,7 @@ function createContextMenu(text: string, id: ContextMenuCommand) {
"*://*.youtube.com/*",
"*://*.reddit.com/*",
"*://*.twitter.com/*",
"*://*.t.co/*",
"*://medium.com/*",
"*://disqus.com/*",
"*://*.tumblr.com/*",

View File

@ -367,8 +367,17 @@ function getIdentifierFromElementImpl(element: HTMLAnchorElement): string {
p = p.parentElement;
}
}
} else if(hostname == 'twitter.com') {
if (dataset && dataset.expandedUrl) return getIdentifier(dataset.expandedUrl);
if (element.href.startsWith('https://t.co/')) {
const title = element.title;
if (title && (title.startsWith('http://') || title.startsWith('https://')))
return getIdentifier(title);
const content = element.textContent;
if(!content.includes(' ') && content.includes('.'))
return getIdentifier('http://' + content);
}
}
if (dataset && dataset.expandedUrl) return getIdentifierFromURLImpl(tryParseURL(dataset.expandedUrl));
if (element.classList.contains('tumblelog')) return element.textContent.substr(1) + '.tumblr.com';