@@ -127,7 +127,7 @@ function showNagMaybe() {
127
127
if ( POPUP_DATA . showLearningPrompt ) {
128
128
_showLearningPrompt ( ) ;
129
129
130
- } else if ( ! POPUP_DATA . seenComic ) {
130
+ } else if ( ! POPUP_DATA . settings . seenComic ) {
131
131
chrome . tabs . query ( { active : true , currentWindow : true } , function ( focusedTab ) {
132
132
// Show the popup instruction if the active tab is not firstRun.html page
133
133
if ( ! focusedTab [ 0 ] . url . startsWith ( intro_page_url ) ) {
@@ -194,6 +194,43 @@ function init() {
194
194
chrome . i18n . getMessage ( "version" , chrome . runtime . getManifest ( ) . version )
195
195
) ;
196
196
197
+ // add event listeners for click-to-expand blocked resources popup section
198
+ $ ( '#tracker-list-header' ) . on ( 'click' , toggleBlockedResourcesHandler ) ;
199
+
200
+ // add event listeners for click-to-expand first party protections popup section
201
+ $ ( '#firstparty-protections-header' ) . on ( 'click' , toggleFirstPartyInfoHandler ) ;
202
+
203
+ // show sliders when sliders were shown last
204
+ // or when there is at least one breakage warning
205
+ if ( POPUP_DATA . settings . showExpandedTrackingSection || (
206
+ POPUP_DATA . cookieblocked && Object . keys ( POPUP_DATA . cookieblocked ) . some (
207
+ d => POPUP_DATA . origins [ d ] == constants . USER_BLOCK )
208
+ ) ) {
209
+ $ ( '#expand-blocked-resources' ) . hide ( ) ;
210
+ $ ( '#collapse-blocked-resources' ) . show ( ) ;
211
+ $ ( '#blockedResources' ) . show ( ) ;
212
+
213
+ } else {
214
+ $ ( '#expand-blocked-resources' ) . show ( ) ;
215
+ $ ( '#collapse-blocked-resources' ) . hide ( ) ;
216
+ // show sliders regardless when the button
217
+ // that lets you toggle slider visibility
218
+ // isn't shown for whatever reason
219
+ // (for ex.: "no trackers blocked" but we need to show
220
+ // one or more "don't appear to be tracking you" sliders)
221
+ if ( ! $ ( '#tracker-list-header' ) . is ( ':visible' ) ) {
222
+ $ ( '#blockedResources' ) . show ( ) ;
223
+ } else {
224
+ $ ( '#blockedResources' ) . hide ( ) ;
225
+ }
226
+ }
227
+
228
+ // show firstparty protections message if current tab is in our content scripts
229
+ if ( POPUP_DATA . enabled && POPUP_DATA . isOnFirstParty ) {
230
+ $ ( "#firstparty-protections-container" ) . show ( ) ;
231
+ $ ( '#expand-firstparty-popup' ) . show ( ) ;
232
+ }
233
+
197
234
// improve on Firefox's built-in options opening logic
198
235
if ( typeof browser == "object" && typeof browser . runtime . getBrowserInfo == "function" ) {
199
236
browser . runtime . getBrowserInfo ( ) . then ( function ( info ) {
@@ -436,6 +473,48 @@ function share() {
436
473
$ ( "#share_output" ) . val ( share_msg ) ;
437
474
}
438
475
476
+ /**
477
+ * Click handlers for showing/hiding the blocked resources section
478
+ */
479
+ function toggleBlockedResourcesHandler ( e ) {
480
+ if ( e . target . nodeName . toLowerCase ( ) == 'a' ) {
481
+ // don't toggle contents when clicking links in the header
482
+ return ;
483
+ }
484
+ if ( $ ( "#expand-blocked-resources" ) . is ( ":visible" ) ) {
485
+ $ ( "#collapse-blocked-resources" ) . show ( ) ;
486
+ $ ( "#expand-blocked-resources" ) . hide ( ) ;
487
+ $ ( "#blockedResources" ) . slideDown ( ) ;
488
+ chrome . runtime . sendMessage ( {
489
+ type : "updateSettings" ,
490
+ data : { showExpandedTrackingSection : true }
491
+ } ) ;
492
+ } else {
493
+ $ ( "#collapse-blocked-resources" ) . hide ( ) ;
494
+ $ ( "#expand-blocked-resources" ) . show ( ) ;
495
+ $ ( "#blockedResources" ) . slideUp ( ) ;
496
+ chrome . runtime . sendMessage ( {
497
+ type : "updateSettings" ,
498
+ data : { showExpandedTrackingSection : false }
499
+ } ) ;
500
+ }
501
+ }
502
+
503
+ /**
504
+ * Click handler for showing/hiding the firstparty popup info text
505
+ */
506
+ function toggleFirstPartyInfoHandler ( ) {
507
+ if ( $ ( '#collapse-firstparty-popup' ) . is ( ":visible" ) ) {
508
+ $ ( "#collapse-firstparty-popup" ) . hide ( ) ;
509
+ $ ( "#expand-firstparty-popup" ) . show ( ) ;
510
+ $ ( "#instructions-firstparty-description" ) . slideUp ( ) ;
511
+ } else {
512
+ $ ( "#collapse-firstparty-popup" ) . show ( ) ;
513
+ $ ( "#expand-firstparty-popup" ) . hide ( ) ;
514
+ $ ( "#instructions-firstparty-description" ) . slideDown ( ) ;
515
+ }
516
+ }
517
+
439
518
/**
440
519
* Handler to undo user selection for a tracker
441
520
*/
@@ -507,14 +586,10 @@ function refreshPopup() {
507
586
}
508
587
509
588
if ( ! originsArr . length ) {
510
- // hide the number of trackers and slider instructions message
511
- // if no sliders will be displayed
512
- $ ( "#instructions-many-trackers" ) . hide ( ) ;
513
-
514
589
// show "no trackers" message
515
590
$ ( "#instructions-no-trackers" ) . show ( ) ;
516
591
517
- if ( POPUP_DATA . learnLocally && POPUP_DATA . showNonTrackingDomains ) {
592
+ if ( POPUP_DATA . settings . learnLocally && POPUP_DATA . settings . showNonTrackingDomains ) {
518
593
// show the "no third party resources on this site" message
519
594
$ ( "#no-third-parties" ) . show ( ) ;
520
595
}
@@ -527,7 +602,8 @@ function refreshPopup() {
527
602
return ;
528
603
}
529
604
530
- let printable = [ ] ;
605
+ let printable = [ ] ,
606
+ printableWarningSliders = [ ] ;
531
607
let unblockedTrackers = [ ] ;
532
608
let nonTracking = [ ] ;
533
609
originsArr = htmlUtils . sortDomains ( originsArr ) ;
@@ -544,13 +620,19 @@ function refreshPopup() {
544
620
action == constants . USER_BLOCK &&
545
621
POPUP_DATA . cookieblocked . hasOwnProperty ( origin )
546
622
) ;
547
- printable . push (
548
- htmlUtils . getOriginHtml ( origin , action , show_breakage_warning )
549
- ) ;
623
+ let slider_html = htmlUtils . getOriginHtml ( origin , action , show_breakage_warning ) ;
624
+ if ( show_breakage_warning ) {
625
+ printableWarningSliders . push ( slider_html ) ;
626
+ } else {
627
+ printable . push ( slider_html ) ;
628
+ }
550
629
}
551
630
}
552
631
553
- if ( POPUP_DATA . learnLocally && unblockedTrackers . length ) {
632
+ // show breakage warning sliders at the top of the list
633
+ printable = printableWarningSliders . concat ( printable ) ;
634
+
635
+ if ( POPUP_DATA . settings . learnLocally && unblockedTrackers . length ) {
554
636
printable . push (
555
637
'<div class="clicker tooltip" id="not-yet-blocked-header" title="' +
556
638
chrome . i18n . getMessage ( "intro_not_an_adblocker_paragraph" ) +
@@ -563,12 +645,9 @@ function refreshPopup() {
563
645
htmlUtils . getOriginHtml ( domain , constants . ALLOW )
564
646
) ;
565
647
} ) ;
566
-
567
- // reduce margin if we have hasn't-decided-yet-to-block domains to show
568
- $ ( "#instructions-no-trackers" ) . css ( "margin" , "10px 0" ) ;
569
648
}
570
649
571
- if ( POPUP_DATA . learnLocally && POPUP_DATA . showNonTrackingDomains && nonTracking . length ) {
650
+ if ( POPUP_DATA . settings . learnLocally && POPUP_DATA . settings . showNonTrackingDomains && nonTracking . length ) {
572
651
printable . push (
573
652
'<div class="clicker tooltip" id="non-trackers-header" title="' +
574
653
chrome . i18n . getMessage ( "non_tracker_tip" ) +
@@ -581,9 +660,6 @@ function refreshPopup() {
581
660
htmlUtils . getOriginHtml ( nonTracking [ i ] , constants . NO_TRACKING )
582
661
) ;
583
662
}
584
-
585
- // reduce margin if we have non-tracking domains to show
586
- $ ( "#instructions-no-trackers" ) . css ( "margin" , "10px 0" ) ;
587
663
}
588
664
589
665
if ( printable . length ) {
@@ -595,13 +671,11 @@ function refreshPopup() {
595
671
$ ( '.tooltip' ) . tooltipster ( ) ;
596
672
597
673
if ( POPUP_DATA . trackerCount === 0 ) {
598
- // hide multiple trackers message
599
- $ ( "#instructions-many-trackers" ) . hide ( ) ;
600
-
601
674
// show "no trackers" message
602
675
$ ( "#instructions-no-trackers" ) . show ( ) ;
603
676
604
677
} else {
678
+ $ ( '#tracker-list-header' ) . show ( ) ;
605
679
$ ( '#instructions-many-trackers' ) . html ( chrome . i18n . getMessage (
606
680
"popup_instructions" , [
607
681
POPUP_DATA . trackerCount ,
0 commit comments