@@ -70,41 +70,93 @@ class ContainerProxyUI {
7070 const containerList = document . getElementById ( 'containerList' ) ;
7171
7272 if ( this . containers . length === 0 ) {
73- containerList . innerHTML = `
74- <div class="loading">
75- <p>No containers found.</p>
76- <p>Create containers in Firefox to assign proxies.</p>
77- </div>
78- ` ;
73+ containerList . textContent = '' ;
74+ const loadingDiv = document . createElement ( 'div' ) ;
75+ loadingDiv . className = 'loading' ;
76+ const p1 = document . createElement ( 'p' ) ;
77+ p1 . textContent = 'No containers found.' ;
78+ const p2 = document . createElement ( 'p' ) ;
79+ p2 . textContent = 'Create containers in Firefox to assign proxies.' ;
80+ loadingDiv . appendChild ( p1 ) ;
81+ loadingDiv . appendChild ( p2 ) ;
82+ containerList . appendChild ( loadingDiv ) ;
7983 return ;
8084 }
8185
82- const containerHTML = this . containers . map ( container => {
86+ // Clear existing content safely
87+ containerList . textContent = '' ;
88+
89+ this . containers . forEach ( container => {
8390 const proxy = this . proxies [ container . cookieStoreId ] ;
8491 const hasProxy = proxy && proxy . enabled ;
8592
86- return `
87- <div class="container-item ${ hasProxy ? 'has-proxy' : '' } ">
88- <div class="container-info">
89- <div class="container-icon" style="background-color: ${ container . color } "></div>
90- <div class="container-details">
91- <h3>${ this . escapeHtml ( container . name ) } </h3>
92- <p>${ hasProxy ? `${ proxy . type } - ${ proxy . host } :${ proxy . port } ${ proxy . label ? ` (${ proxy . label } )` : '' } ` : 'No proxy assigned' } </p>
93- </div>
94- </div>
95- <div class="container-actions">
96- ${ hasProxy ?
97- `<span class="proxy-status enabled">Active</span>
98- <button class="btn btn-primary btn-small" data-action="edit" data-container="${ container . cookieStoreId } ">Edit</button>
99- <button class="btn btn-danger btn-small" data-action="remove" data-container="${ container . cookieStoreId } ">Remove</button>` :
100- `<button class="btn btn-primary btn-small" data-action="add" data-container="${ container . cookieStoreId } " data-container-name="${ this . escapeHtml ( container . name ) } ">Add Proxy</button>`
101- }
102- </div>
103- </div>
104- ` ;
105- } ) . join ( '' ) ;
106-
107- containerList . innerHTML = containerHTML ;
93+ // Create container item
94+ const containerItem = document . createElement ( 'div' ) ;
95+ containerItem . className = `container-item ${ hasProxy ? 'has-proxy' : '' } ` ;
96+
97+ // Container info section
98+ const containerInfo = document . createElement ( 'div' ) ;
99+ containerInfo . className = 'container-info' ;
100+
101+ const containerIcon = document . createElement ( 'div' ) ;
102+ containerIcon . className = 'container-icon' ;
103+ containerIcon . style . backgroundColor = container . color ;
104+
105+ const containerDetails = document . createElement ( 'div' ) ;
106+ containerDetails . className = 'container-details' ;
107+
108+ const nameHeader = document . createElement ( 'h3' ) ;
109+ nameHeader . textContent = container . name ;
110+
111+ const proxyInfo = document . createElement ( 'p' ) ;
112+ proxyInfo . textContent = hasProxy ?
113+ `${ proxy . type } - ${ proxy . host } :${ proxy . port } ${ proxy . label ? ` (${ proxy . label } )` : '' } ` :
114+ 'No proxy assigned' ;
115+
116+ containerDetails . appendChild ( nameHeader ) ;
117+ containerDetails . appendChild ( proxyInfo ) ;
118+ containerInfo . appendChild ( containerIcon ) ;
119+ containerInfo . appendChild ( containerDetails ) ;
120+
121+ // Container actions section
122+ const containerActions = document . createElement ( 'div' ) ;
123+ containerActions . className = 'container-actions' ;
124+
125+ if ( hasProxy ) {
126+ const proxyStatus = document . createElement ( 'span' ) ;
127+ proxyStatus . className = 'proxy-status enabled' ;
128+ proxyStatus . textContent = 'Active' ;
129+
130+ const editBtn = document . createElement ( 'button' ) ;
131+ editBtn . className = 'btn btn-primary btn-small' ;
132+ editBtn . textContent = 'Edit' ;
133+ editBtn . dataset . action = 'edit' ;
134+ editBtn . dataset . container = container . cookieStoreId ;
135+
136+ const removeBtn = document . createElement ( 'button' ) ;
137+ removeBtn . className = 'btn btn-danger btn-small' ;
138+ removeBtn . textContent = 'Remove' ;
139+ removeBtn . dataset . action = 'remove' ;
140+ removeBtn . dataset . container = container . cookieStoreId ;
141+
142+ containerActions . appendChild ( proxyStatus ) ;
143+ containerActions . appendChild ( editBtn ) ;
144+ containerActions . appendChild ( removeBtn ) ;
145+ } else {
146+ const addBtn = document . createElement ( 'button' ) ;
147+ addBtn . className = 'btn btn-primary btn-small' ;
148+ addBtn . textContent = 'Add Proxy' ;
149+ addBtn . dataset . action = 'add' ;
150+ addBtn . dataset . container = container . cookieStoreId ;
151+ addBtn . dataset . containerName = container . name ;
152+
153+ containerActions . appendChild ( addBtn ) ;
154+ }
155+
156+ containerItem . appendChild ( containerInfo ) ;
157+ containerItem . appendChild ( containerActions ) ;
158+ containerList . appendChild ( containerItem ) ;
159+ } ) ;
108160
109161 // Add event delegation for dynamically created buttons
110162 containerList . addEventListener ( 'click' , ( e ) => {
0 commit comments