Skip to content

Commit 9673d30

Browse files
Tweaks: Fix subtle following/mutuals indicators option (#1654)
Co-authored-by: April Sylph <[email protected]>
1 parent 151709c commit 9673d30

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

src/features/tweaks/subtle_activity_mutuals.js

+34-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import { keyToCss } from '../../utils/css_map.js';
33
import { buildStyle } from '../../utils/interface.js';
44
import { dom } from '../../utils/dom.js';
55

6-
const labelSelector = `${keyToCss('followingBadgeContainer', 'mutualsBadgeContainer')}:has(> svg)`;
6+
const labelSelector = `${keyToCss('activity', 'activityItem')} ${keyToCss('followingBadgeContainer', 'mutualsBadgeContainer')}`;
77

88
const spanClass = 'xkit-tweaks-subtle-activity-span';
9+
const iconClass = 'xkit-tweaks-subtle-activity-icon';
910

1011
export const styleElement = buildStyle(`
1112
.${spanClass} {
@@ -15,13 +16,25 @@ export const styleElement = buildStyle(`
1516
width: var(--rendered-width);
1617
}
1718
18-
a:not(:hover) .${spanClass} {
19+
${keyToCss('tumblelogName', 'activityHeader')}:not(:hover) .${spanClass} {
1920
width: 0;
2021
}
2122
22-
a:not(:hover) ${labelSelector} > svg {
23+
${keyToCss('tumblelogName', 'activityHeader')}:not(:hover) :is(${labelSelector}) > svg {
2324
margin-left: 0;
2425
}
26+
27+
${keyToCss('activityHeader')} div:has(> .${spanClass}) {
28+
/* fixes hover detection when covered by the "activityItemLink" <a> element */
29+
isolation: isolate;
30+
}
31+
32+
.${iconClass} {
33+
vertical-align: middle;
34+
margin-left: 4px;
35+
position: relative;
36+
bottom: 1px;
37+
}
2538
`);
2639

2740
const transitionStyleElement = buildStyle(`
@@ -37,6 +50,23 @@ const processLabels = labels => labels.forEach(label => {
3750
const textNode = label.firstChild;
3851
if (textNode.nodeName !== '#text') return;
3952

53+
if (!label.querySelector('svg')) {
54+
const iconHref = label.matches(keyToCss('mutualsBadgeContainer'))
55+
? '#managed-icon__profile-double'
56+
: '#managed-icon__profile-checkmark';
57+
58+
if (!document.querySelector(iconHref)) return;
59+
60+
label.append(
61+
dom(
62+
'svg',
63+
{ class: iconClass, width: 14, height: 14, xmlns: 'http://www.w3.org/2000/svg' },
64+
null,
65+
[dom('use', { href: iconHref, xmlns: 'http://www.w3.org/2000/svg' })]
66+
)
67+
);
68+
}
69+
4070
const span = dom('span', null, null, [textNode.textContent]);
4171
label.insertBefore(span, textNode);
4272
textNode.textContent = '';
@@ -62,4 +92,5 @@ export const clean = async function () {
6292
const textNode = document.createTextNode(span.textContent);
6393
span.parentNode.replaceChild(textNode, span);
6494
});
95+
$(`.${iconClass}`).remove();
6596
};

0 commit comments

Comments
 (0)