This repository was archived by the owner on Jul 9, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change 17
17
position : absolute;
18
18
right : 0 ;
19
19
}
20
+
21
+ .zero-width-character : after {
22
+ color : red;
23
+ content : '\25CF' ;
24
+ }
Original file line number Diff line number Diff line change 1
1
( function ( ) {
2
2
let elementsWithZWCC = [ ] ;
3
3
4
+ /**
5
+ * Highlight zero-width character in DOM element
6
+ *
7
+ * @param {dom node } element A DOM node.
8
+ */
9
+ const highlightCharacters = function ( element ) {
10
+ const zeroWidthCharacters = String . fromCodePoint ( ...zeroWidthCharacterCodes ) ;
11
+ const regExp = new RegExp ( `([${ zeroWidthCharacters } ])` , 'g' )
12
+
13
+ element . innerHTML = element . innerHTML
14
+ . replace ( regExp , '$1<span class="zero-width-character"></span>' ) ;
15
+ } ;
16
+
4
17
/**
5
18
* Checks DOM element for zero-width character.
6
19
*
22
35
elementsWithZWCC . push ( element )
23
36
}
24
37
} ) ;
25
-
26
- elementsWithZWCC . forEach ( function ( element ) {
27
- element . classList . add ( 'zero-width-characters' ) ;
28
- } )
29
38
}
30
39
31
40
/**
59
68
*/
60
69
const checkPage = function ( ) {
61
70
const allElements = document . getElementsByTagName ( '*' ) ;
62
- [ ...allElements ] . forEach ( checkElement ) ;
71
+
72
+ [ ...allElements ] . forEach ( checkElement ) ;
73
+
74
+ elementsWithZWCC . forEach ( function ( element ) {
75
+ element . classList . add ( 'zero-width-characters' ) ;
76
+ highlightCharacters ( element ) ;
77
+ } ) ;
63
78
}
64
79
65
80
chrome . extension . sendMessage ( { } , function ( response ) {
You can’t perform that action at this time.
0 commit comments