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 1717 position : absolute;
1818 right : 0 ;
1919}
20+
21+ .zero-width-character : after {
22+ color : red;
23+ content : '\25CF' ;
24+ }
Original file line number Diff line number Diff line change 11( function ( ) {
22 let elementsWithZWCC = [ ] ;
33
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+
417 /**
518 * Checks DOM element for zero-width character.
619 *
2235 elementsWithZWCC . push ( element )
2336 }
2437 } ) ;
25-
26- elementsWithZWCC . forEach ( function ( element ) {
27- element . classList . add ( 'zero-width-characters' ) ;
28- } )
2938 }
3039
3140 /**
5968 */
6069 const checkPage = function ( ) {
6170 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+ } ) ;
6378 }
6479
6580 chrome . extension . sendMessage ( { } , function ( response ) {
You can’t perform that action at this time.
0 commit comments