@@ -3,44 +3,34 @@ import { render } from 'react-dom'
33import minimatch from 'minimatch'
44
55import App from './App'
6+ import { getElement } from './utils'
67
7- if ( minimatch ( location . href , 'https://leetcode-cn.com/submissions/detail/**' ) ) {
8- window . onload = ( ) => {
9- const parent =
10- document . querySelectorAll ( '#lc-header+div' ) ?. [ 0 ] ?. children ?. [ 0 ]
11- if ( parent && parent instanceof HTMLElement ) {
12- parent . style . display = 'flex'
13- parent . style . justifyContent = 'space-between'
14- const root = document . createElement ( 'div' )
15- parent . append ( root )
8+ function loadDownload ( parent : Element ) {
9+ if ( parent && parent instanceof HTMLElement ) {
10+ parent . style . display = 'flex'
11+ parent . style . justifyContent = 'space-between'
12+ const root = document . createElement ( 'div' )
13+ parent . append ( root )
1614
17- render (
18- < StrictMode >
19- < App />
20- </ StrictMode > ,
21- root
22- )
23- }
15+ render (
16+ < StrictMode >
17+ < App />
18+ </ StrictMode > ,
19+ root
20+ )
2421 }
2522}
2623
27- if ( minimatch ( location . href , 'https://leetcode.com/submissions/detail/**' ) ) {
28- window . onload = ( ) => {
29- const parent =
30- document . getElementById ( 'submission-app' ) ?. children ?. [ 0 ] ?. children ?. [ 0 ]
31-
32- if ( parent && parent instanceof HTMLElement ) {
33- parent . style . display = 'flex'
34- parent . style . justifyContent = 'space-between'
35- const root = document . createElement ( 'div' )
36- parent . append ( root )
24+ if ( minimatch ( location . href , 'https://leetcode-cn.com/submissions/detail/**' ) ) {
25+ window . onload = async ( ) => {
26+ const main = await getElement ( '.css-smuvek-Main' )
27+ loadDownload ( main [ 0 ] ?. children ?. [ 0 ] )
28+ }
29+ }
3730
38- render (
39- < StrictMode >
40- < App />
41- </ StrictMode > ,
42- root
43- )
44- }
31+ if ( minimatch ( location . href , 'https://leetcode.com/submissions/detail/**' ) ) {
32+ window . onload = async ( ) => {
33+ const parent = await getElement ( '#submission-app>.row>div:first-child' )
34+ loadDownload ( parent [ 0 ] )
4535 }
4636}
0 commit comments