@@ -81,7 +81,7 @@ addEventListener(kPageShow, onBFCache);
81
81
async function init ( ) {
82
82
if ( isUnstylable ) return API . styleViaAPI ( { method : 'styleApply' } ) ;
83
83
let data ;
84
- if ( __ . ENTRY && ( data = global . clientData ) ) {
84
+ if ( __ . ENTRY && ( data = global [ __ . CLIENT_DATA ] ) ) {
85
85
data = ( /**@type {StylusClientData }*/ __ . MV3 ? data : await data ) . apply ;
86
86
} else {
87
87
data = isFrameNoUrl && ! FF && clone ( parent [ parent . Symbol . for ( SYM_ID ) ] ) ;
@@ -90,11 +90,11 @@ async function init() {
90
90
// XML in Chrome will be auto-converted to html later, so we can't style it via XHR now
91
91
}
92
92
if ( ! chrome . runtime . id ) return selfDestruct ( ) ;
93
- await applyStyles ( data ) ;
93
+ await applyStyles ( data , true ) ;
94
94
}
95
95
96
- async function applyStyles ( data ) {
97
- if ( ! data ) data = await API . styles . getSectionsByUrl ( matchUrl , null , ! own . sections ) ;
96
+ async function applyStyles ( data , isInitial = ! own . sections ) {
97
+ if ( ! data ) data = await API . styles . getSectionsByUrl ( matchUrl , null , isInitial ) ;
98
98
if ( ! data . cfg ) data . cfg = own . cfg ;
99
99
Object . assign ( own , window [ Symbol . for ( SYM_ID ) ] = data ) ;
100
100
if ( ! isFrame && own . cfg . top === '' ) own . cfg . top = location . origin ; // used by child frames via parentStyles
@@ -229,7 +229,7 @@ function updateCount() {
229
229
230
230
function onFrameElementInView ( cb ) {
231
231
parent [ parent . Symbol . for ( 'xo' ) ] ( frameElement , cb ) ;
232
- ( offscreen || ( offscreen = [ ] ) ) . push ( cb ) ;
232
+ ( offscreen ?? = [ ] ) . push ( cb ) ;
233
233
}
234
234
235
235
/** @param {IntersectionObserverEntry[] } entries */
@@ -247,7 +247,7 @@ function onBFCache(e) {
247
247
if ( ! chrome . runtime . id ) return selfDestruct ( ) ;
248
248
if ( e . isTrusted && e . persisted ) {
249
249
throttledCount = '' ;
250
- updateCount ( ) ;
250
+ init ( ) ; // styles may have been toggled while we were in bfcache
251
251
}
252
252
}
253
253
0 commit comments