Don't highlight all threads of a labeled subreddit

This commit is contained in:
shinigami-eyes 2019-02-08 21:00:04 +01:00
parent 352334d668
commit 38a9029f42

View File

@ -228,13 +228,6 @@ function initLink(a) {
var identifier = getIdentifier(a); var identifier = getIdentifier(a);
if (!identifier) return; if (!identifier) return;
if (hostname == 'reddit.com') {
if (a.classList.contains('title')) return; // post title (classic)
var parent = a.parentNode;
if (parent && parent.parentNode && parent.parentNode.classList.contains('flat-list')) return; // post buttons (classic)
if (a.id && a.id.startsWith('CommentTopMeta')) return; // post date (redesign)
}
var label = knownLabels[identifier]; var label = knownLabels[identifier];
if (label === undefined) { if (label === undefined) {
labelsToSolve.push({ element: a, identifier: identifier }); labelsToSolve.push({ element: a, identifier: identifier });
@ -318,6 +311,11 @@ function getIdentifier(urlstr) {
function getIdentifierInternal(urlstr) { function getIdentifierInternal(urlstr) {
if (!urlstr) return null; if (!urlstr) return null;
if (hostname == 'reddit.com') {
var parent = urlstr.parentElement;
if (parent && parent.classList.contains('domain') && urlstr.textContent.startsWith('self.')) return null;
}
if (hostname == 'facebook.com') { if (hostname == 'facebook.com') {
var parent = urlstr.parentElement; var parent = urlstr.parentElement;
if (parent && (parent.tagName == 'H1' || parent.id == 'fb-timeline-cover-name')) { if (parent && (parent.tagName == 'H1' || parent.id == 'fb-timeline-cover-name')) {
@ -408,6 +406,7 @@ function getIdentifierInternal(urlstr) {
if (isHostedOn(host, 'reddit.com')) { if (isHostedOn(host, 'reddit.com')) {
var pathname = url.pathname.replace('/u/', '/user/'); var pathname = url.pathname.replace('/u/', '/user/');
if (!pathname.startsWith('/user/') && !pathname.startsWith('/r/')) return null; if (!pathname.startsWith('/user/') && !pathname.startsWith('/r/')) return null;
if(pathname.includes('/comments/')) return null;
return 'reddit.com' + takeFirstPathComponents(pathname, 2); return 'reddit.com' + takeFirstPathComponents(pathname, 2);
} }
if (isHostedOn(host, 'twitter.com')) { if (isHostedOn(host, 'twitter.com')) {