@@ -47,6 +47,39 @@ class TargetSelector {
47
47
this . div = div
48
48
this . e = null
49
49
this . r = null
50
+ this . banner = doc . createElement ( 'div' )
51
+ this . banner . setAttribute (
52
+ 'style' ,
53
+ 'position: fixed;top: 0;left: 0;bottom: 0;right: 0;background: trasparent;z-index: 10000;'
54
+ )
55
+ const header = doc . createElement ( 'div' )
56
+ header . setAttribute (
57
+ 'style' ,
58
+ "pointer-events: none;display: flex;align-items: center;justify-content: center;flex-direction: row;position: fixed;top: 20%;left: 35%;right: 35%;background: whitesmoke;color: #444;font-size: 28px;line-height: 50px;z-index: 10001;font-family: system, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;box-shadow: 7px 7px 10px 0 rgba(0,0,0,0.3);border: 1px white solid;"
59
+ )
60
+ const img = doc . createElement ( 'img' )
61
+ img . src = browser . runtime . getURL ( '/icons/icon128.png' )
62
+ img . setAttribute ( 'style' , 'width: 28px;margin-right: 15px;' )
63
+ header . appendChild ( img )
64
+ const span = doc . createElement ( 'span' )
65
+ span . innerText = 'Select an element'
66
+ header . appendChild ( span )
67
+ setTimeout ( ( ) => {
68
+ // this has to happen after a timeout, since adding it sync will add the event
69
+ // before the window is focused which will case mousemove to fire before the
70
+ // user actually moves the mouse
71
+ this . banner . addEventListener (
72
+ 'mousemove' ,
73
+ ( ) => {
74
+ setTimeout ( ( ) => {
75
+ this . banner . style . visibility = 'hidden'
76
+ } , 300 )
77
+ } ,
78
+ false
79
+ )
80
+ } , 300 )
81
+ this . banner . appendChild ( header )
82
+ doc . body . insertBefore ( this . banner , div )
50
83
doc . addEventListener ( 'mousemove' , this , true )
51
84
doc . addEventListener ( 'click' , this , true )
52
85
}
@@ -59,6 +92,12 @@ class TargetSelector {
59
92
}
60
93
this . div = null
61
94
}
95
+ if ( this . header ) {
96
+ if ( this . header . parentNode ) {
97
+ this . header . parentNode . removeChild ( this . header )
98
+ }
99
+ this . header = null
100
+ }
62
101
if ( this . win ) {
63
102
const doc = this . win . document
64
103
doc . removeEventListener ( 'mousemove' , this , true )
@@ -101,7 +140,7 @@ class TargetSelector {
101
140
}
102
141
103
142
highlightElement ( element ) {
104
- if ( element && element != this . e ) {
143
+ if ( element && element != this . e && element !== this . banner ) {
105
144
this . e = element
106
145
} else {
107
146
return
0 commit comments