|
165 | 165 | // SITES UI
|
166 | 166 | let sitesUI = new UI.Sites(document.getElementById("sites"));
|
167 | 167 | let containerSelect = document.querySelector("#select-container");
|
| 168 | + let containerCopy = document.querySelector("#copy-container"); |
168 | 169 | var cookieStoreId = containerSelect.value;
|
169 | 170 | var currentPolicy = await UI.getPolicy(cookieStoreId);
|
170 | 171 |
|
|
178 | 179 | }
|
179 | 180 | containerSelect.onchange = changeContainer;
|
180 | 181 |
|
| 182 | + async function copyContainer() { |
| 183 | + cookieStoreId = containerSelect.value; |
| 184 | + let copyCookieStoreId = containerCopy.value; |
| 185 | + let copyContainerName = containerCopy.options[containerCopy.selectedIndex].text; |
| 186 | + let copyPolicy = await UI.getPolicy(copyCookieStoreId); |
| 187 | + if (confirm(`Copying permissions from "${copyContainerName}".\n` + "All site permissions for this container will be removed.\nThis action cannot be reverted.\nDo you want to continue?")) { |
| 188 | + sitesUI.clear() |
| 189 | + currentPolicy = await UI.replacePolicy(cookieStoreId, new Policy(copyPolicy.dry(true))); |
| 190 | + await UI.updateSettings({policy, contextStore}); |
| 191 | + sitesUI.render(currentPolicy.sites); |
| 192 | + } |
| 193 | + sitesUI.clear() |
| 194 | + sitesUI.policy = currentPolicy; |
| 195 | + sitesUI.render(currentPolicy.sites); |
| 196 | + } |
| 197 | + containerCopy.onchange = copyContainer; |
| 198 | + |
181 | 199 | var containers = [];
|
182 | 200 | async function updateContainers() {
|
183 | 201 | let newContainers = [{cookieStoreId: "default", name: "Default"},];
|
|
193 | 211 | }
|
194 | 212 | containerSelect.innerHTML = container_options;
|
195 | 213 | containerSelect.value = cookieStoreId;
|
| 214 | + containerCopy.innerHTML = container_options; |
196 | 215 | }
|
197 | 216 | containerSelect.onfocus = updateContainers;
|
| 217 | + containerCopy.onfocus = updateContainers; |
198 | 218 | await updateContainers();
|
199 | 219 |
|
200 | 220 | UI.onSettings = async () => {
|
|
0 commit comments