@@ -175,17 +175,7 @@ function onBeforeRequest(details) {
175
175
}
176
176
177
177
if ( ( type == 'script' || sw_request ) && from_current_tab ) {
178
- let surrogate ;
179
-
180
- if ( utils . hasOwn ( surrogates . WIDGET_SURROGATES , request_host ) ) {
181
- let settings = badger . getSettings ( ) ;
182
- if ( ! settings . getItem ( 'widgetReplacementExceptions' ) . includes ( surrogates . WIDGET_SURROGATES [ request_host ] . widgetName ) ) {
183
- surrogate = surrogates . getSurrogateUri ( url , request_host ) ;
184
- }
185
-
186
- } else {
187
- surrogate = surrogates . getSurrogateUri ( url , request_host ) ;
188
- }
178
+ let surrogate = surrogates . getSurrogateUri ( url , request_host ) ;
189
179
190
180
if ( surrogate ) {
191
181
let secret = getWarSecret ( tab_id , frame_id , surrogate ) ;
@@ -625,11 +615,7 @@ function hideBlockedFrame(tab_id, parent_frame_id, frame_url, frame_host) {
625
615
}
626
616
627
617
// don't hide widget frames
628
- let exceptions = badger . getSettings ( ) . getItem ( 'widgetReplacementExceptions' ) ;
629
618
for ( let widget of badger . widgetList ) {
630
- if ( exceptions . includes ( widget . name ) ) {
631
- continue ;
632
- }
633
619
for ( let domain of widget . domains ) {
634
620
if ( domain == frame_host ) {
635
621
return ;
@@ -844,8 +830,7 @@ let getWidgetList = (function () {
844
830
let widgetsToReplace = { } ,
845
831
widgetList = [ ] ,
846
832
trackers = badger . tabData . getTrackers ( tab_id ) ,
847
- trackerDomains = Object . keys ( trackers ) ,
848
- exceptions = badger . getSettings ( ) . getItem ( 'widgetReplacementExceptions' ) ;
833
+ trackerDomains = Object . keys ( trackers ) ;
849
834
850
835
// optimize translation lookups by doing them just once,
851
836
// the first time they are needed
@@ -862,12 +847,6 @@ let getWidgetList = (function () {
862
847
}
863
848
864
849
for ( let widget of badger . widgetList ) {
865
- // replace only if the widget is not on the 'do not replace' list
866
- // also don't send widget data used later for dynamic replacement
867
- if ( exceptions . includes ( widget . name ) ) {
868
- continue ;
869
- }
870
-
871
850
widgetList . push ( widget ) ;
872
851
873
852
// replace only if we haven't already allowed this widget for the tab/site
@@ -1004,13 +983,24 @@ function getWidgetDomains(widget_name) {
1004
983
* with domains for widgets marked as always allowed on a given site.
1005
984
*/
1006
985
function initAllowedWidgets ( tab_id , tab_host ) {
1007
- let allowedWidgets = badger . getSettings ( ) . getItem ( 'widgetSiteAllowlist' ) ;
1008
- if ( utils . hasOwn ( allowedWidgets , tab_host ) ) {
1009
- for ( let widget_name of allowedWidgets [ tab_host ] ) {
1010
- let widgetDomains = getWidgetDomains ( widget_name ) ;
1011
- if ( widgetDomains ) {
1012
- badger . tabData . allowOnTab ( tab_id , widgetDomains , widget_name ) ;
1013
- }
986
+ let allowedWidgets = { } ,
987
+ conf = badger . getSettings ( ) ;
988
+
989
+ for ( let widget_name of conf . getItem ( 'widgetAllowlist' ) ) {
990
+ allowedWidgets [ widget_name ] = true ;
991
+ }
992
+
993
+ let siteExceptions = conf . getItem ( 'widgetSiteAllowlist' ) ;
994
+ if ( utils . hasOwn ( siteExceptions , tab_host ) ) {
995
+ for ( let widget_name of siteExceptions [ tab_host ] ) {
996
+ allowedWidgets [ widget_name ] = true ;
997
+ }
998
+ }
999
+
1000
+ for ( let name of Object . keys ( allowedWidgets ) ) {
1001
+ let widgetDomains = getWidgetDomains ( name ) ;
1002
+ if ( widgetDomains ) {
1003
+ badger . tabData . allowOnTab ( tab_id , widgetDomains , name ) ;
1014
1004
}
1015
1005
}
1016
1006
}
0 commit comments