@@ -263,18 +263,28 @@ export function applyCaptchaFrameVisibility(candidates, frameContexts, navigatio
263263 const candidate = reconcileAncestorLoader ( rawCandidate ) ;
264264 const frameVisible = frameIsVisible ( candidate ?. frameId )
265265 && candidate ?. frameVisibleWithinAnchor !== false ;
266+ const visible = candidate ?. visible === true && frameVisible ;
266267 return {
267268 ...candidate ,
268269 frameVisible,
269270 websiteURL : nearestHttpUrl ( candidate ) ,
270271 dialogAssociated : candidate ?. dialogAssociated === true
271272 || frameIsDialogAssociated ( candidate ?. frameId ) ,
272- visible : candidate ?. visible === true && frameVisible ,
273+ visible,
273274 normalCheckbox : candidate ?. normalCheckbox === true && candidate ?. visible === true && frameVisible ,
275+ activeChallengeFrameVisible : candidate ?. activeChallengeFrame === true && visible ,
274276 } ;
275277 } ) ;
276278}
277279
280+ function isVisibleActiveChallengeFrame ( candidate ) {
281+ if ( candidate ?. activeChallengeFrameVisible === true ) return true ;
282+ if ( candidate ?. activeChallengeFrameVisible === false ) return false ;
283+ return candidate ?. activeChallengeFrame === true
284+ && candidate ?. visible === true
285+ && candidate ?. frameVisible !== false ;
286+ }
287+
278288function candidateSummary ( candidate ) {
279289 return {
280290 frameId : Number . isInteger ( candidate ?. frameId ) ? candidate . frameId : null ,
@@ -292,6 +302,7 @@ function candidateSummary(candidate) {
292302 normalCheckbox : candidate ?. normalCheckbox === true ,
293303 challengeFrame : candidate ?. challengeFrame === true ,
294304 activeChallengeFrame : candidate ?. activeChallengeFrame === true ,
305+ activeChallengeFrameVisible : isVisibleActiveChallengeFrame ( candidate ) ,
295306 dialogAssociated : candidate ?. dialogAssociated === true ,
296307 frameVisible : candidate ?. frameVisible !== false ,
297308 isInvisible : candidate ?. isInvisible === true ,
@@ -327,9 +338,7 @@ function candidateScore(candidate) {
327338 // Priority is tiered so no combination of secondary signals can make a
328339 // generic visible/background integration outrank an active challenge
329340 // frame or visible checkbox.
330- const activeChallengeFrame = candidate ?. activeChallengeFrame
331- && candidate ?. visible === true
332- && candidate ?. frameVisible !== false ;
341+ const activeChallengeFrame = isVisibleActiveChallengeFrame ( candidate ) ;
333342 const primary = ( candidate ?. normalCheckbox && candidate ?. visible ) || activeChallengeFrame ;
334343 const tier = primary ? 3 : ( candidate ?. visible ? 2 : 1 ) ;
335344 let score = tier * 1000 ;
@@ -409,6 +418,8 @@ export function selectCaptchaCandidate(candidates, constraints = {}) {
409418 challengeFrame : previous . challengeFrame === true || candidate . challengeFrame === true ,
410419 activeChallengeFrame : previous . activeChallengeFrame === true
411420 || candidate . activeChallengeFrame === true ,
421+ activeChallengeFrameVisible : isVisibleActiveChallengeFrame ( previous )
422+ || isVisibleActiveChallengeFrame ( candidate ) ,
412423 dialogAssociated : previous . dialogAssociated === true || candidate . dialogAssociated === true ,
413424 responseField : previous . responseField === true || candidate . responseField === true ,
414425 responseTokenPresent : previous . responseTokenPresent === true
@@ -583,7 +594,7 @@ function selectedReason(candidate, constraints) {
583594 if ( constraints . frameUrl ) return 'exact frameUrl match' ;
584595 if ( constraints . websiteKey ) return 'exact websiteKey match' ;
585596 if ( candidate . normalCheckbox && candidate . visible ) return 'visible checkbox challenge' ;
586- if ( candidate . visible && candidate . activeChallengeFrame && candidate . frameVisible !== false ) return 'visible challenge frame' ;
597+ if ( isVisibleActiveChallengeFrame ( candidate ) ) return 'visible challenge frame' ;
587598 if ( candidate . visible ) return 'visible CAPTCHA widget' ;
588599 if ( candidate . challengeFrame && candidate . frameVisible !== false ) return 'challenge frame candidate' ;
589600 return 'only detected CAPTCHA candidate' ;
0 commit comments