@@ -9,7 +9,7 @@ var copyMarkdownSnippetFromGithub = (function(){ // ES6 modules are not supporte
99 }
1010
1111 async function highlightGitHubSeletedLines ( ) {
12- let lines = document . querySelectorAll ( '.js-file-line.highlighted' ) ;
12+ let lines = findSelectedLines ( ) ;
1313 if ( lines . length === 0 ) {
1414 lines = document . querySelectorAll ( 'div[aria-current]' ) ;
1515 }
@@ -19,16 +19,20 @@ var copyMarkdownSnippetFromGithub = (function(){ // ES6 modules are not supporte
1919 }
2020
2121 function convertLineElToText ( lineEl ) {
22- let lines = Array . from ( lineEl . querySelector ( '.react-file-line' ) . childNodes ) ;
22+ let lines = Array . from ( lineEl . childNodes ) ;
2323 let textFragments = Array . prototype . map . call ( lines , line => line . textContent )
2424 return textFragments . join ( '' )
2525 }
2626
27- function readHighlightedLines ( ) {
28- // Read code lines highlighted on GitHub page, return multiline string
27+ function findSelectedLines ( ) {
2928 let lines = Array . from ( document . querySelectorAll ( '.highlighted-line' ) ) ;
3029 const numbers = lines . map ( line => line . getAttribute ( 'data-line-number' ) ) ;
31- let texts = numbers . map ( number => document . querySelector ( `[data-key="${ number - 1 } "]` ) )
30+ return numbers . map ( number => document . querySelector ( `[id="LC${ number } "]` ) ) ;
31+ }
32+
33+ function readHighlightedLines ( ) {
34+ // Read code lines highlighted on GitHub page, return multiline string
35+ let texts = findSelectedLines ( ) ;
3236 if ( texts . length === 0 ) {
3337 texts = document . querySelectorAll ( 'div[aria-current]' ) ;
3438 }
0 commit comments