@@ -23,7 +23,6 @@ var UI = (() => {
2323
2424 var UI = {
2525 initialized : false ,
26- isBrowserAction : false ,
2726
2827 presets : {
2928 "DEFAULT" : "Default" ,
@@ -404,9 +403,8 @@ var UI = (() => {
404403 UI . Sites = class {
405404 constructor ( parentNode , presets = DEF_PRESETS ) {
406405 this . parentNode = parentNode ;
407- let policy = UI . policy ;
408406 this . uiCount = UI . Sites . count = ( UI . Sites . count || 0 ) + 1 ;
409- this . sites = policy . sites ;
407+ this . sites = UI . policy . sites ;
410408 this . presets = presets ;
411409 this . customizing = null ;
412410 this . typesMap = new Map ( ) ;
@@ -499,7 +497,12 @@ var UI = (() => {
499497 let sizer = document . createElement ( "div" ) ;
500498 sizer . id = "presets-sizer" ;
501499 sizer . classList . add ( "sites" ) ;
502- sizer . appendChild ( presets . cloneNode ( true ) ) ;
500+ const presetsCopy = sizer . appendChild ( presets . cloneNode ( true ) ) ;
501+ if ( "isBrowserAction" in UI && UI . policy . autoAllowTop ) {
502+ const customCopy = presetsCopy . querySelector ( ".preset.CUSTOM" ) ;
503+ customCopy . querySelector ( "label.preset" ) . textContent = _ ( "AutoTrustedLabel" ) ;
504+ customCopy . parentNode . appendChild ( customCopy ) ;
505+ }
503506 document . body . appendChild ( sizer ) ;
504507 let labelWidth = 0 ;
505508 let biggest = "" ;
@@ -663,6 +666,7 @@ var UI = (() => {
663666 } else if ( ! ( isCap || isTemp || customizer ) && ev . type === "click" ) {
664667 this . customize ( row . perms , preset , row ) ;
665668 }
669+ this . _customOrAuto ( row ) ;
666670 }
667671
668672 setupCaps ( perms , preset , row ) {
@@ -1026,6 +1030,26 @@ var UI = (() => {
10261030 return changed ;
10271031 }
10281032
1033+ _customOrAuto ( row ) {
1034+ const { policy } = UI ;
1035+ const { perms, contextMatch, siteMatch } = row ;
1036+ const isAuto = policy . autoAllowTop && perms . temp &&
1037+ contextMatch == siteMatch &&
1038+ perms . sameAs ( policy . TRUSTED ) ;
1039+ if ( ! ( isAuto || row . _wasAuto ) ) {
1040+ return ;
1041+ }
1042+ row . _wasAuto = true ;
1043+ const [ labelShort , title ] = isAuto
1044+ ? [ _ ( "AutoTrustedLabel" ) , _ ( "autoAllowTop" ) ]
1045+ : [ _ ( "Custom" ) , _ ( "Custom" ) ] ;
1046+ const widgets = row . querySelectorAll ( ".preset.CUSTOM [title]" ) ;
1047+ for ( const w of [ ...widgets ] ) {
1048+ w . title = title ;
1049+ if ( w . textContent ) w . textContent = labelShort ;
1050+ }
1051+ }
1052+
10291053 createSiteRow (
10301054 site ,
10311055 siteMatch ,
@@ -1040,9 +1064,10 @@ var UI = (() => {
10401064 contextMatch ,
10411065 perms
10421066 ) ;
1043- let policy = UI . policy ;
1067+ const { policy } = UI ;
10441068 let row = this . rowTemplate . cloneNode ( true ) ;
10451069 row . sitesCount = sitesCount ;
1070+
10461071 let url ;
10471072 try {
10481073 url = new URL ( site ) ;
@@ -1123,7 +1148,6 @@ var UI = (() => {
11231148 : punycode . toUnicode (
11241149 hostname . substring ( 0 , hostname . length - domain . length )
11251150 ) ;
1126-
11271151 row . querySelector ( ".domain" ) . textContent = unicodeDomain ;
11281152 row . querySelector ( ".path" ) . textContent =
11291153 siteMatch . length > url . origin . length ? url . pathname : "" ;
@@ -1222,6 +1246,8 @@ var UI = (() => {
12221246 }
12231247 preset . disabled = false ;
12241248 }
1249+
1250+ this . _customOrAuto ( row ) ;
12251251 return row ;
12261252 }
12271253
0 commit comments