* Adding in hide/show API for containers * fix #12: [un]hide icons in the pop-up UI
This commit is contained in:
parent
38a4eb68ec
commit
3c06f76ab3
7 changed files with 1455 additions and 10 deletions
|
@ -1,4 +1,8 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"extends": "nightmare-mode",
|
"extends": "nightmare-mode",
|
||||||
"installedESLint": true
|
"installedESLint": true,
|
||||||
|
"rules": {
|
||||||
|
// Consider moving to this as is FF default
|
||||||
|
// "quotes": ["error", "double"]
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@
|
||||||
node_modules
|
node_modules
|
||||||
README.html
|
README.html
|
||||||
*.xpi
|
*.xpi
|
||||||
|
*.swp
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -25,8 +25,34 @@
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"name": "cookieStoreId",
|
"name": "cookiestoreid",
|
||||||
"description": "The ID of the contextual identity cookie store. "
|
"description": "the id of the contextual identity cookie store. "
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "hide",
|
||||||
|
"type": "function",
|
||||||
|
"description": "hides all of a contextual identity.",
|
||||||
|
"async": true,
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"name": "cookiestoreid",
|
||||||
|
"description": "the id of the contextual identity cookie store. "
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "show",
|
||||||
|
"type": "function",
|
||||||
|
"description": "unhides all of a contextual identity.",
|
||||||
|
"async": true,
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"name": "cookiestoreid",
|
||||||
|
"description": "the id of the contextual identity cookie store. "
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -39,6 +39,12 @@ table.unstriped tbody tr {
|
||||||
height: 32px;
|
height: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hideorshow-icon {
|
||||||
|
max-width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
margin: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
.edit-identities {
|
.edit-identities {
|
||||||
background: #DCDBDC;
|
background: #DCDBDC;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,70 @@
|
||||||
|
/* global browser, window, document */
|
||||||
|
const identityState = {
|
||||||
|
};
|
||||||
|
|
||||||
|
function hideContainer(containerId) {
|
||||||
|
const hideorshowIcon = document.querySelector(`#${containerId}-hideorshow-icon`);
|
||||||
|
|
||||||
|
hideorshowIcon.src = '/img/container-unhide.svg';
|
||||||
|
browser.contextualIdentities.hide(containerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
function showContainer(containerId) {
|
||||||
|
const hideorshowIcon = document.querySelector(`#${containerId}-hideorshow-icon`);
|
||||||
|
|
||||||
|
hideorshowIcon.src = '/img/container-hide.svg';
|
||||||
|
browser.contextualIdentities.show(containerId);
|
||||||
|
}
|
||||||
|
|
||||||
browser.contextualIdentities.query({}).then(identites=> {
|
browser.contextualIdentities.query({}).then(identites=> {
|
||||||
let customContainerStyles = '';
|
|
||||||
const identitiesListElement = document.querySelector('.identities-list');
|
const identitiesListElement = document.querySelector('.identities-list');
|
||||||
|
|
||||||
identites.forEach(identity=> {
|
identites.forEach(identity=> {
|
||||||
const identityRow = `
|
const identityRow = `
|
||||||
<tr>
|
<tr data-identity-cookie-store-id="${identity.cookieStoreId}" >
|
||||||
<td><div class="userContext-icon"
|
<td><div class="userContext-icon"
|
||||||
data-identity-icon="${identity.icon}"
|
data-identity-icon="${identity.icon}"
|
||||||
data-identity-color="${identity.color}"
|
data-identity-color="${identity.color}"
|
||||||
></div></td>
|
></div></td>
|
||||||
<td>${identity.name}</td>
|
<td>${identity.name}</td>
|
||||||
|
<td class="hideorshow" >
|
||||||
|
<img
|
||||||
|
data-identity-cookie-store-id="${identity.cookieStoreId}"
|
||||||
|
id="${identity.cookieStoreId}-hideorshow-icon"
|
||||||
|
class="hideorshow-icon"
|
||||||
|
src="/img/container-hide.svg"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
<td>></td>
|
<td>></td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
|
|
||||||
identitiesListElement.innerHTML += identityRow;
|
identitiesListElement.innerHTML += identityRow;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
const rows = identitiesListElement.querySelectorAll('tr');
|
||||||
|
|
||||||
|
rows.forEach(row=> {
|
||||||
|
row.addEventListener('click', e=> {
|
||||||
|
if (e.target.matches('.hideorshow-icon')) {
|
||||||
|
const containerId = e.target.dataset.identityCookieStoreId;
|
||||||
|
|
||||||
|
if (!(containerId in identityState)) {
|
||||||
|
identityState[containerId] = true;
|
||||||
|
}
|
||||||
|
if (identityState[containerId]) {
|
||||||
|
hideContainer(containerId);
|
||||||
|
identityState[containerId] = false;
|
||||||
|
} else {
|
||||||
|
showContainer(containerId);
|
||||||
|
identityState[containerId] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
document.querySelector('#edit-containers-link').addEventListener('click', ()=> {
|
document.querySelector('#edit-containers-link').addEventListener('click', ()=> {
|
||||||
browser.runtime.sendMessage('open-containers-preferences').then(()=> {
|
browser.runtime.sendMessage('open-containers-preferences').then(()=> {
|
||||||
window.close();
|
window.close();
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
"homepage_url": "https://testpilot.firefox.com/",
|
"homepage_url": "https://testpilot.firefox.com/",
|
||||||
|
|
||||||
"permissions": [
|
"permissions": [
|
||||||
|
"cookies",
|
||||||
"experiments.contextualidentities",
|
"experiments.contextualidentities",
|
||||||
"contextualidentities"
|
"contextualidentities"
|
||||||
],
|
],
|
||||||
|
|
Loading…
Add table
Reference in a new issue