@@ -402,24 +402,7 @@ async function createPlaceholderElementAndReplace (widget, trackingElement) {
402
402
replaceTrackingElement (
403
403
widget , trackingElement , contentBlock
404
404
)
405
-
406
- // Show the extra unblock link in the header if the placeholder or
407
- // its parent is too short for the normal unblock button to be visible.
408
- // Note: This does not take into account the placeholder's vertical
409
- // position in the parent element.
410
- const { height : placeholderHeight } = window . getComputedStyle ( contentBlock )
411
- const { height : parentHeight } = window . getComputedStyle ( contentBlock . parentElement )
412
- if ( parseInt ( placeholderHeight , 10 ) <= 200 || parseInt ( parentHeight , 10 ) <= 200 ) {
413
- const titleRowTextButton = shadowRoot . querySelector ( `#${ titleID + 'TextButton' } ` )
414
- titleRowTextButton . style . display = 'block'
415
-
416
- // Avoid the placeholder being taller than the containing element
417
- // and overflowing.
418
- const innerDiv = shadowRoot . querySelector ( '.DuckDuckGoSocialContainer' )
419
- innerDiv . style . minHeight = ''
420
- innerDiv . style . maxHeight = parentHeight
421
- innerDiv . style . overflow = 'hidden'
422
- }
405
+ showExtraUnblockIfShortPlaceholder ( shadowRoot , contentBlock )
423
406
}
424
407
425
408
/** YouTube CTL */
@@ -475,19 +458,30 @@ async function replaceYouTubeCTL (trackingElement, widget, togglePlaceholder = f
475
458
}
476
459
477
460
/**
478
- / * Show the extra unblock link in the header if the placeholder or
479
- / * its parent is too short for the normal unblock button to be visible.
480
- / * Note: This does not take into account the placeholder's vertical
481
- / * position in the parent element.
482
- * @param {Element } shadowRoot
483
- * @param {Element } placeholder Placeholder for tracking element
484
- */
461
+ * Show the extra unblock link in the header if the placeholder or
462
+ * its parent is too short for the normal unblock button to be visible.
463
+ * Note: This does not take into account the placeholder's vertical
464
+ * position in the parent element.
465
+ * @param {Element } shadowRoot
466
+ * @param {Element } placeholder Placeholder for tracking element
467
+ */
485
468
function showExtraUnblockIfShortPlaceholder ( shadowRoot , placeholder ) {
469
+ if ( ! placeholder . parentElement ) {
470
+ return
471
+ }
472
+
486
473
const { height : placeholderHeight } = window . getComputedStyle ( placeholder )
487
474
const { height : parentHeight } = window . getComputedStyle ( placeholder . parentElement )
488
475
if ( parseInt ( placeholderHeight , 10 ) <= 200 || parseInt ( parentHeight , 10 ) <= 200 ) {
489
476
const titleRowTextButton = shadowRoot . querySelector ( `#${ titleID + 'TextButton' } ` )
490
477
titleRowTextButton . style . display = 'block'
478
+
479
+ // Avoid the placeholder being taller than the containing element
480
+ // and overflowing.
481
+ const innerDiv = shadowRoot . querySelector ( '.DuckDuckGoSocialContainer' )
482
+ innerDiv . style . minHeight = ''
483
+ innerDiv . style . maxHeight = parentHeight
484
+ innerDiv . style . overflow = 'hidden'
491
485
}
492
486
}
493
487
0 commit comments