@@ -15,7 +15,7 @@ import { applyCompiledSelector, compileProceduralSelector } from './procedural_f
15
15
return $ . postNativeMessage ( messageHandler , {
16
16
"securityToken" : SECURITY_TOKEN ,
17
17
"data" : {
18
- sourceURL : window . location . href ,
18
+ windowOrigin : $ . windowOrigin ,
19
19
ids : ids ,
20
20
classes : classes
21
21
}
@@ -32,7 +32,7 @@ import { applyCompiledSelector, compileProceduralSelector } from './procedural_f
32
32
return $ . postNativeMessage ( partinessMessageHandler , {
33
33
"securityToken" : SECURITY_TOKEN ,
34
34
"data" : {
35
- sourceURL : window . location . href ,
35
+ windowOrigin : $ . windowOrigin ,
36
36
urls : urls ,
37
37
}
38
38
} )
@@ -201,8 +201,11 @@ import { applyCompiledSelector, compileProceduralSelector } from './procedural_f
201
201
* @returns True or false indicating if anything was extracted
202
202
*/
203
203
const extractIDSelectorIfNeeded = ( element ) => {
204
- const id = element . id
204
+ const id = element . getAttribute ( 'id' )
205
205
if ( ! id ) { return false }
206
+ if ( typeof id !== 'string' && ! ( id instanceof String ) ) {
207
+ return false
208
+ }
206
209
const selector = `#${ id } `
207
210
if ( ! CC . allSelectors . has ( selector ) ) {
208
211
CC . allSelectors . add ( selector )
@@ -1012,12 +1015,24 @@ import { applyCompiledSelector, compileProceduralSelector } from './procedural_f
1012
1015
styleElm . setAttribute ( 'type' , 'text/css' )
1013
1016
targetElm . appendChild ( styleElm )
1014
1017
CC . cosmeticStyleSheet = styleElm
1018
+ // The previous `nextElementSibling` we moved our stylesheet below
1019
+ var prevNextElementSibling = null ;
1015
1020
1016
1021
// Start a timer that moves the stylesheet down
1017
1022
window . setInterval ( ( ) => {
1018
1023
if ( styleElm . nextElementSibling === null || styleElm . parentElement !== targetElm ) {
1019
1024
return
1020
1025
}
1026
+ if ( styleElm . nextElementSibling !== null ) {
1027
+ // if we already moved below this element
1028
+ if ( prevNextElementSibling === styleElm . nextElementSibling ) {
1029
+ // Avoid a loop where we are repeatedly swapping places with another
1030
+ // element. This can happen with `darkreader` (night mode) for
1031
+ // example and cause unwanted animations to repeat.
1032
+ return
1033
+ }
1034
+ prevNextElementSibling = styleElm . nextElementSibling ;
1035
+ }
1021
1036
moveStyle ( )
1022
1037
} , 1000 )
1023
1038
}
0 commit comments