@@ -84,6 +84,12 @@ const NetFilteringResultCache = class {
8484        this . hash  =  now ; 
8585    } 
8686
87+     forgetResult ( fctxt )  { 
88+         const  key  =  `${ fctxt . getDocHostname ( ) }   ${ fctxt . type }   ${ fctxt . url }  ` ; 
89+         this . results . delete ( key ) ; 
90+         this . blocked . delete ( key ) ; 
91+     } 
92+ 
8793    empty ( )  { 
8894        this . blocked . clear ( ) ; 
8995        this . results . clear ( ) ; 
@@ -165,6 +171,7 @@ const FrameStore = class {
165171    init ( frameURL )  { 
166172        this . t0  =  Date . now ( ) ; 
167173        this . exceptCname  =  undefined ; 
174+         this . clickToLoad  =  0 ; 
168175        this . rawURL  =  frameURL ; 
169176        if  (  frameURL  !==  undefined  )  { 
170177            this . hostname  =  vAPI . hostnameFromURI ( frameURL ) ; 
@@ -253,7 +260,7 @@ const PageStore = class {
253260
254261        this . frameAddCount  =  0 ; 
255262        this . frames  =  new  Map ( ) ; 
256-         this . setFrame ( 0 ,  tabContext . rawURL ) ; 
263+         this . setFrameURL ( 0 ,  tabContext . rawURL ) ; 
257264
258265        // The current filtering context is cloned because: 
259266        // - We may be called with or without the current context having been 
@@ -308,7 +315,7 @@ const PageStore = class {
308315            // As part of https://github.com/chrisaljoudi/uBlock/issues/405 
309316            // URL changed, force a re-evaluation of filtering switch 
310317            this . rawURL  =  tabContext . rawURL ; 
311-             this . setFrame ( 0 ,  this . rawURL ) ; 
318+             this . setFrameURL ( 0 ,  this . rawURL ) ; 
312319            return  this ; 
313320        } 
314321
@@ -353,20 +360,23 @@ const PageStore = class {
353360        this . frames . clear ( ) ; 
354361    } 
355362
356-     getFrame ( frameId )  { 
363+     getFrameStore ( frameId )  { 
357364        return  this . frames . get ( frameId )  ||  null ; 
358365    } 
359366
360-     setFrame ( frameId ,  frameURL )  { 
361-         const  frameStore  =  this . frames . get ( frameId ) ; 
367+     setFrameURL ( frameId ,  frameURL )  { 
368+         let  frameStore  =  this . frames . get ( frameId ) ; 
362369        if  (  frameStore  !==  undefined  )  { 
363370            frameStore . init ( frameURL ) ; 
364-             return ; 
371+         }  else  { 
372+             frameStore  =  FrameStore . factory ( frameURL ) ; 
373+             this . frames . set ( frameId ,  frameStore ) ; 
374+             this . frameAddCount  +=  1 ; 
375+             if  (  ( this . frameAddCount  &  0b111111 )  ===  0  )  { 
376+                 this . pruneFrames ( ) ; 
377+             } 
365378        } 
366-         this . frames . set ( frameId ,  FrameStore . factory ( frameURL ) ) ; 
367-         this . frameAddCount  +=  1 ; 
368-         if  (  ( this . frameAddCount  &  0b111111 )  !==  0  )  {  return ;  } 
369-         this . pruneFrames ( ) ; 
379+         return  frameStore ; 
370380    } 
371381
372382    // There is no event to tell us a specific subframe has been removed from 
@@ -597,6 +607,22 @@ const PageStore = class {
597607            } 
598608        } 
599609
610+         // Click-to-load: 
611+         // When frameId is not -1, the resource is always sub_frame. 
612+         if  (  result  ===  1  &&  fctxt . frameId  !==  - 1  )  { 
613+             const  docStore  =  this . getFrameStore ( fctxt . frameId ) ; 
614+             if  (  docStore  !==  null  &&  docStore . clickToLoad  !==  0  )  { 
615+                 result  =  2 ; 
616+                 if  (  µb . logger . enabled  )  { 
617+                     fctxt . setFilter ( { 
618+                         result, 
619+                         source : 'network' , 
620+                         raw : 'click-to-load' , 
621+                     } ) ; 
622+                 } 
623+             } 
624+         } 
625+ 
600626        if  (  cacheableResult  )  { 
601627            this . netFilteringCache . rememberResult ( fctxt ,  result ) ; 
602628        }  else  if  ( 
@@ -696,11 +722,19 @@ const PageStore = class {
696722        return  1 ; 
697723    } 
698724
725+     clickToLoad ( frameId ,  frameURL )  { 
726+         let  frameStore  =  this . getFrameStore ( frameId ) ; 
727+         if  (  frameStore  ===  null  )  { 
728+             frameStore  =  this . setFrameURL ( frameId ,  frameURL ) ; 
729+         } 
730+         frameStore . clickToLoad  =  Date . now ( ) ; 
731+     } 
732+ 
699733    shouldExceptCname ( fctxt )  { 
700734        let  exceptCname ; 
701735        let  frameStore ; 
702736        if  (  fctxt . docId  !==  undefined  )  { 
703-             frameStore  =  this . getFrame ( fctxt . docId ) ; 
737+             frameStore  =  this . getFrameStore ( fctxt . docId ) ; 
704738            if  (  frameStore  instanceof  Object  )  { 
705739                exceptCname  =  frameStore . exceptCname ; 
706740            } 
@@ -742,17 +776,24 @@ const PageStore = class {
742776        // content script-side (i.e. `iframes` -- unlike `img`). 
743777        if  (  Array . isArray ( resources )  &&  resources . length  !==  0  )  { 
744778            for  (  const  resource  of  resources  )  { 
745-                 this . filterRequest ( 
746-                     fctxt . setType ( resource . type ) 
747-                          . setURL ( resource . url ) 
779+                 const  result  =  this . filterRequest ( 
780+                     fctxt . setType ( resource . type ) . setURL ( resource . url ) 
748781                ) ; 
782+                 if  (  result  ===  1  &&  µb . redirectEngine . toURL ( fctxt )  )  { 
783+                     this . forgetBlockedResource ( fctxt ) ; 
784+                 } 
749785            } 
750786        } 
751787        if  (  this . netFilteringCache . hash  ===  response . hash  )  {  return ;  } 
752788        response . hash  =  this . netFilteringCache . hash ; 
753789        response . blockedResources  = 
754790            this . netFilteringCache . lookupAllBlocked ( fctxt . getDocHostname ( ) ) ; 
755791    } 
792+ 
793+     forgetBlockedResource ( fctxt )  { 
794+         if  (  this . collapsibleResources . has ( fctxt . type )  ===  false  )  {  return ;  } 
795+         this . netFilteringCache . forgetResult ( fctxt ) ; 
796+     } 
756797} ; 
757798
758799PageStore . prototype . cacheableResults  =  new  Set ( [ 
0 commit comments