@@ -226,9 +226,9 @@ const PageStore = class {
226
226
constructor ( tabId , context ) {
227
227
this . extraData = new Map ( ) ;
228
228
this . journal = [ ] ;
229
- this . journalTimer = null ;
230
- this . journalLastCommitted = this . journalLastUncommitted = undefined ;
231
- this . journalLastUncommittedURL = undefined ;
229
+ this . journalTimer = undefined ;
230
+ this . journalLastCommitted = this . journalLastUncommitted = - 1 ;
231
+ this . journalLastUncommittedOrigin = undefined ;
232
232
this . netFilteringCache = NetFilteringResultCache . factory ( ) ;
233
233
this . init ( tabId , context ) ;
234
234
}
@@ -351,12 +351,12 @@ const PageStore = class {
351
351
this . largeMediaTimer = null ;
352
352
}
353
353
this . disposeFrameStores ( ) ;
354
- if ( this . journalTimer !== null ) {
354
+ if ( this . journalTimer !== undefined ) {
355
355
clearTimeout ( this . journalTimer ) ;
356
- this . journalTimer = null ;
356
+ this . journalTimer = undefined ;
357
357
}
358
358
this . journal = [ ] ;
359
- this . journalLastUncommittedURL = undefined ;
359
+ this . journalLastUncommittedOrigin = undefined ;
360
360
if ( pageStoreJunkyard . length < pageStoreJunkyardMax ) {
361
361
pageStoreJunkyard . push ( this ) ;
362
362
}
@@ -463,7 +463,7 @@ const PageStore = class {
463
463
hostname ,
464
464
result === 1 ? 0x00000001 : 0x00010000
465
465
) ;
466
- if ( this . journalTimer === null ) {
466
+ if ( this . journalTimer === undefined ) {
467
467
this . journalTimer = vAPI . setTimeout (
468
468
( ) => { this . journalProcess ( true ) ; } ,
469
469
µb . hiddenSettings . requestJournalProcessPeriod
@@ -475,18 +475,23 @@ const PageStore = class {
475
475
if ( type === 'committed' ) {
476
476
this . journalLastCommitted = this . journal . length ;
477
477
if (
478
- this . journalLastUncommitted !== undefined &&
478
+ this . journalLastUncommitted !== - 1 &&
479
479
this . journalLastUncommitted < this . journalLastCommitted &&
480
- this . journalLastUncommittedURL === url
480
+ this . journalLastUncommittedOrigin === vAPI . hostnameFromURI ( url )
481
481
) {
482
482
this . journalLastCommitted = this . journalLastUncommitted ;
483
- this . journalLastUncommitted = undefined ;
484
483
}
485
484
} else if ( type === 'uncommitted' ) {
486
- this . journalLastUncommitted = this . journal . length ;
487
- this . journalLastUncommittedURL = url ;
485
+ const newOrigin = vAPI . hostnameFromURI ( url ) ;
486
+ if (
487
+ this . journalLastUncommitted === - 1 ||
488
+ this . journalLastUncommittedOrigin !== newOrigin
489
+ ) {
490
+ this . journalLastUncommitted = this . journal . length ;
491
+ this . journalLastUncommittedOrigin = newOrigin ;
492
+ }
488
493
}
489
- if ( this . journalTimer !== null ) {
494
+ if ( this . journalTimer !== undefined ) {
490
495
clearTimeout ( this . journalTimer ) ;
491
496
}
492
497
this . journalTimer = vAPI . setTimeout (
@@ -495,16 +500,14 @@ const PageStore = class {
495
500
) ;
496
501
}
497
502
498
- journalProcess ( fromTimer ) {
499
- if ( ! fromTimer ) {
500
- clearTimeout ( this . journalTimer ) ;
501
- }
502
- this . journalTimer = null ;
503
+ journalProcess ( fromTimer = false ) {
504
+ if ( fromTimer === false ) { clearTimeout ( this . journalTimer ) ; }
505
+ this . journalTimer = undefined ;
503
506
504
507
const journal = this . journal ;
508
+ const pivot = this . journalLastCommitted || 0 ;
505
509
const now = Date . now ( ) ;
506
510
let aggregateCounts = 0 ;
507
- let pivot = this . journalLastCommitted || 0 ;
508
511
509
512
// Everything after pivot originates from current page.
510
513
for ( let i = pivot ; i < journal . length ; i += 2 ) {
@@ -520,7 +523,7 @@ const PageStore = class {
520
523
}
521
524
this . perLoadBlockedRequestCount += aggregateCounts & 0xFFFF ;
522
525
this . perLoadAllowedRequestCount += aggregateCounts >>> 16 & 0xFFFF ;
523
- this . journalLastCommitted = undefined ;
526
+ this . journalLastUncommitted = this . journalLastCommitted = - 1 ;
524
527
525
528
// https://github.com/chrisaljoudi/uBlock/issues/905#issuecomment-76543649
526
529
// No point updating the badge if it's not being displayed.
0 commit comments