@@ -3,9 +3,10 @@ import { keyToCss } from '../../utils/css_map.js';
3
3
import { buildStyle } from '../../utils/interface.js' ;
4
4
import { dom } from '../../utils/dom.js' ;
5
5
6
- const labelSelector = `${ keyToCss ( 'followingBadgeContainer ' , 'mutualsBadgeContainer ' ) } :has(> svg) ` ;
6
+ const labelSelector = `${ keyToCss ( 'activity ' , 'activityItem ' ) } ${ keyToCss ( 'followingBadgeContainer' , 'mutualsBadgeContainer' ) } ` ;
7
7
8
8
const spanClass = 'xkit-tweaks-subtle-activity-span' ;
9
+ const iconClass = 'xkit-tweaks-subtle-activity-icon' ;
9
10
10
11
export const styleElement = buildStyle ( `
11
12
.${ spanClass } {
@@ -15,13 +16,25 @@ export const styleElement = buildStyle(`
15
16
width: var(--rendered-width);
16
17
}
17
18
18
- a :not(:hover) .${ spanClass } {
19
+ ${ keyToCss ( 'tumblelogName' , 'activityHeader' ) } :not(:hover) .${ spanClass } {
19
20
width: 0;
20
21
}
21
22
22
- a :not(:hover) ${ labelSelector } > svg {
23
+ ${ keyToCss ( 'tumblelogName' , 'activityHeader' ) } :not(:hover) :is( ${ labelSelector } ) > svg {
23
24
margin-left: 0;
24
25
}
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
+ }
25
38
` ) ;
26
39
27
40
const transitionStyleElement = buildStyle ( `
@@ -37,6 +50,23 @@ const processLabels = labels => labels.forEach(label => {
37
50
const textNode = label . firstChild ;
38
51
if ( textNode . nodeName !== '#text' ) return ;
39
52
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
+
40
70
const span = dom ( 'span' , null , null , [ textNode . textContent ] ) ;
41
71
label . insertBefore ( span , textNode ) ;
42
72
textNode . textContent = '' ;
@@ -62,4 +92,5 @@ export const clean = async function () {
62
92
const textNode = document . createTextNode ( span . textContent ) ;
63
93
span . parentNode . replaceChild ( textNode , span ) ;
64
94
} ) ;
95
+ $ ( `.${ iconClass } ` ) . remove ( ) ;
65
96
} ;
0 commit comments