From 38a9029f42e439da8f61a273453cbdd1ccfb5ddc Mon Sep 17 00:00:00 2001 From: shinigami-eyes <43276258+shinigami-eyes@users.noreply.github.com> Date: Fri, 8 Feb 2019 21:00:04 +0100 Subject: [PATCH] Don't highlight all threads of a labeled subreddit --- extension/content.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/extension/content.js b/extension/content.js index 5ff5e70..56d4ce4 100644 --- a/extension/content.js +++ b/extension/content.js @@ -228,13 +228,6 @@ function initLink(a) { var identifier = getIdentifier(a); 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]; if (label === undefined) { labelsToSolve.push({ element: a, identifier: identifier }); @@ -318,6 +311,11 @@ function getIdentifier(urlstr) { function getIdentifierInternal(urlstr) { 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') { var parent = urlstr.parentElement; if (parent && (parent.tagName == 'H1' || parent.id == 'fb-timeline-cover-name')) { @@ -408,6 +406,7 @@ function getIdentifierInternal(urlstr) { if (isHostedOn(host, 'reddit.com')) { var pathname = url.pathname.replace('/u/', '/user/'); if (!pathname.startsWith('/user/') && !pathname.startsWith('/r/')) return null; + if(pathname.includes('/comments/')) return null; return 'reddit.com' + takeFirstPathComponents(pathname, 2); } if (isHostedOn(host, 'twitter.com')) {