Skip to content

Commit 418a056

Browse files
committed
update v1.0.3 add webRequestBlocking to manifest
1 parent 348327c commit 418a056

File tree

3 files changed

+155
-58
lines changed

3 files changed

+155
-58
lines changed

manifest.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"manifest_version": 3,
33
"name": "Container Proxy",
4-
"version": "1.0.1",
4+
"version": "1.0.3",
55
"description": "Assign different proxies to Firefox containers for secure browsing",
66

77
"permissions": [
88
"storage",
99
"contextualIdentities",
1010
"proxy",
11-
"webRequest"
11+
"webRequest",
12+
"webRequestBlocking"
1213
],
1314

1415
"host_permissions": [

options.js

Lines changed: 71 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,41 +22,85 @@ async function loadContainerOverview() {
2222
const overview = document.getElementById('containerOverview');
2323

2424
if (containers.length === 0) {
25-
overview.innerHTML = `
26-
<p>No containers found. <a href="#" onclick="openContainerManager()">Create some containers</a> to get started.</p>
27-
`;
25+
// Safe DOM manipulation instead of innerHTML
26+
overview.textContent = '';
27+
const p = document.createElement('p');
28+
p.textContent = 'No containers found. ';
29+
const link = document.createElement('a');
30+
link.href = '#';
31+
link.textContent = 'Create some containers';
32+
link.onclick = openContainerManager;
33+
p.appendChild(link);
34+
p.appendChild(document.createTextNode(' to get started.'));
35+
overview.appendChild(p);
2836
return;
2937
}
3038

31-
const containerHTML = containers.map(container => {
39+
// Clear existing content safely
40+
overview.textContent = '';
41+
42+
containers.forEach(container => {
3243
const proxy = proxies[container.cookieStoreId];
3344
const hasProxy = proxy && proxy.enabled;
3445

35-
return `
36-
<div class="container-item ${hasProxy ? 'has-proxy' : ''}">
37-
<div class="container-info">
38-
<div class="container-icon" style="background-color: ${container.color}"></div>
39-
<div class="container-details">
40-
<h3>${escapeHtml(container.name)}</h3>
41-
<p><strong>ID:</strong> ${container.cookieStoreId}</p>
42-
<p><strong>Proxy:</strong> ${hasProxy ? `${proxy.type} - ${proxy.host}:${proxy.port}` : 'None assigned'}</p>
43-
</div>
44-
</div>
45-
<div class="container-actions">
46-
${hasProxy ?
47-
'<span class="proxy-status enabled">Proxy Active</span>' :
48-
'<span class="proxy-status disabled">No Proxy</span>'
49-
}
50-
</div>
51-
</div>
52-
`;
53-
}).join('');
54-
55-
overview.innerHTML = containerHTML;
46+
// Create container item element
47+
const containerItem = document.createElement('div');
48+
containerItem.className = `container-item ${hasProxy ? 'has-proxy' : ''}`;
49+
50+
// Container info section
51+
const containerInfo = document.createElement('div');
52+
containerInfo.className = 'container-info';
53+
54+
const containerIcon = document.createElement('div');
55+
containerIcon.className = 'container-icon';
56+
containerIcon.style.backgroundColor = container.color;
57+
58+
const containerDetails = document.createElement('div');
59+
containerDetails.className = 'container-details';
60+
61+
const nameHeader = document.createElement('h3');
62+
nameHeader.textContent = container.name;
63+
64+
const idParagraph = document.createElement('p');
65+
idParagraph.innerHTML = '<strong>ID:</strong> ';
66+
idParagraph.appendChild(document.createTextNode(container.cookieStoreId));
67+
68+
const proxyParagraph = document.createElement('p');
69+
proxyParagraph.innerHTML = '<strong>Proxy:</strong> ';
70+
proxyParagraph.appendChild(document.createTextNode(
71+
hasProxy ? `${proxy.type} - ${proxy.host}:${proxy.port}` : 'None assigned'
72+
));
73+
74+
containerDetails.appendChild(nameHeader);
75+
containerDetails.appendChild(idParagraph);
76+
containerDetails.appendChild(proxyParagraph);
77+
78+
containerInfo.appendChild(containerIcon);
79+
containerInfo.appendChild(containerDetails);
80+
81+
// Container actions section
82+
const containerActions = document.createElement('div');
83+
containerActions.className = 'container-actions';
84+
85+
const proxyStatus = document.createElement('span');
86+
proxyStatus.className = `proxy-status ${hasProxy ? 'enabled' : 'disabled'}`;
87+
proxyStatus.textContent = hasProxy ? 'Proxy Active' : 'No Proxy';
88+
containerActions.appendChild(proxyStatus);
89+
90+
// Assemble the container item
91+
containerItem.appendChild(containerInfo);
92+
containerItem.appendChild(containerActions);
93+
94+
overview.appendChild(containerItem);
95+
});
5696
} catch (error) {
5797
console.error('Error loading container overview:', error);
58-
document.getElementById('containerOverview').innerHTML =
59-
'<p style="color: red;">Error loading container information.</p>';
98+
const overview = document.getElementById('containerOverview');
99+
overview.textContent = '';
100+
const errorP = document.createElement('p');
101+
errorP.style.color = 'red';
102+
errorP.textContent = 'Error loading container information.';
103+
overview.appendChild(errorP);
60104
}
61105
}
62106

popup.js

Lines changed: 81 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)