Merge branch 'master' into eslint-6.6.0
This commit is contained in:
commit
924a52ae23
8 changed files with 61 additions and 56 deletions
|
@ -59,6 +59,6 @@ Finally, we also publish the release to GitHub for those followers.
|
||||||
|
|
||||||
Facebook & Twitter icons CC-Attrib https://fairheadcreative.com.
|
Facebook & Twitter icons CC-Attrib https://fairheadcreative.com.
|
||||||
|
|
||||||
- [Licence](./LICENSE.txt)
|
- [License](./LICENSE.txt)
|
||||||
- [Contributing](./CONTRIBUTING.md)
|
- [Contributing](./CONTRIBUTING.md)
|
||||||
- [Code Of Conduct](./CODE_OF_CONDUCT.md)
|
- [Code Of Conduct](./CODE_OF_CONDUCT.md)
|
||||||
|
|
|
@ -754,21 +754,24 @@ span ~ .panel-header-text {
|
||||||
background: var(--primary-action-color);
|
background: var(--primary-action-color);
|
||||||
block-size: 100%;
|
block-size: 100%;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
display: flex;
|
display: inline-block;
|
||||||
flex: 1;
|
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
padding-block-start: 6px;
|
||||||
|
padding-inline-start: 30%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.exit-edit-mode-link::before {
|
.edit-containers-panel-footer {
|
||||||
background: url('/img/container-arrow.svg') no-repeat;
|
background: var(--primary-action-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.exit-edit-mode-link img {
|
||||||
block-size: 16px;
|
block-size: 16px;
|
||||||
content: "";
|
display: inline;
|
||||||
display: block;
|
|
||||||
filter: grayscale(100%) brightness(5);
|
filter: grayscale(100%) brightness(5);
|
||||||
float: left;
|
|
||||||
inline-size: 16px;
|
inline-size: 16px;
|
||||||
margin-inline-end: 5px;
|
margin-inline-end: 5px;
|
||||||
transform: scaleX(-1);
|
transform: scaleX(-1);
|
||||||
|
vertical-align: bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
.delete-container-confirm {
|
.delete-container-confirm {
|
||||||
|
|
|
@ -240,19 +240,26 @@ const assignManager = {
|
||||||
delete this.canceledRequests[options.tabId];
|
delete this.canceledRequests[options.tabId];
|
||||||
}
|
}
|
||||||
},{urls: ["<all_urls>"], types: ["main_frame"]});
|
},{urls: ["<all_urls>"], types: ["main_frame"]});
|
||||||
this.getPermissions();
|
this.resetBookmarksMenuItem();
|
||||||
},
|
},
|
||||||
|
|
||||||
async getPermissions() {
|
async resetBookmarksMenuItem() {
|
||||||
const {permissions} = await browser.permissions.getAll();
|
const hasPermission = await browser.permissions.contains({permissions: ["bookmarks"]});
|
||||||
permissions.includes("bookmarks") ? this.makeBookmarksMenu() : browser.contextMenus.remove(this.OPEN_IN_CONTAINER);
|
if (this.hadBookmark === hasPermission) {
|
||||||
},
|
return;
|
||||||
|
}
|
||||||
makeBookmarksMenu() {
|
this.hadBookmark = hasPermission;
|
||||||
|
if (hasPermission) {
|
||||||
this.initBookmarksMenu();
|
this.initBookmarksMenu();
|
||||||
browser.contextualIdentities.onCreated.addListener(this.contextualIdentityCreated);
|
browser.contextualIdentities.onCreated.addListener(this.contextualIdentityCreated);
|
||||||
browser.contextualIdentities.onUpdated.addListener(this.contextualIdentityUpdated);
|
browser.contextualIdentities.onUpdated.addListener(this.contextualIdentityUpdated);
|
||||||
browser.contextualIdentities.onRemoved.addListener(this.contextualIdentityRemoved);
|
browser.contextualIdentities.onRemoved.addListener(this.contextualIdentityRemoved);
|
||||||
|
} else {
|
||||||
|
this.removeBookmarksMenu();
|
||||||
|
browser.contextualIdentities.onCreated.removeListener(this.contextualIdentityCreated);
|
||||||
|
browser.contextualIdentities.onUpdated.removeListener(this.contextualIdentityUpdated);
|
||||||
|
browser.contextualIdentities.onRemoved.removeListener(this.contextualIdentityRemoved);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
contextualIdentityCreated(changeInfo) {
|
contextualIdentityCreated(changeInfo) {
|
||||||
|
@ -324,7 +331,7 @@ const assignManager = {
|
||||||
if(openInReaderMode) {
|
if(openInReaderMode) {
|
||||||
try {
|
try {
|
||||||
const parsed = new URL(bookmark.url);
|
const parsed = new URL(bookmark.url);
|
||||||
bookmark.url = parsed.searchParams.get("url") + parsed.hash; // can't believe const lets me do this ...
|
bookmark.url = parsed.searchParams.get("url") + parsed.hash;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return err.message;
|
return err.message;
|
||||||
}
|
}
|
||||||
|
@ -521,6 +528,14 @@ const assignManager = {
|
||||||
icons: { "16": `img/usercontext.svg#${identity.icon}` }
|
icons: { "16": `img/usercontext.svg#${identity.icon}` }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async removeBookmarksMenu() {
|
||||||
|
browser.contextMenus.remove(this.OPEN_IN_CONTAINER);
|
||||||
|
const identities = await browser.contextualIdentities.query({});
|
||||||
|
for (const identity of identities) {
|
||||||
|
browser.contextMenus.remove(identity.cookieStoreId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ const messageHandler = {
|
||||||
|
|
||||||
switch (m.method) {
|
switch (m.method) {
|
||||||
case "resetBookmarksContext":
|
case "resetBookmarksContext":
|
||||||
response = assignManager.getPermissions();
|
response = assignManager.resetBookmarksMenuItem();
|
||||||
break;
|
break;
|
||||||
case "deleteContainer":
|
case "deleteContainer":
|
||||||
response = backgroundLogic.deleteContainer(m.message.userContextId);
|
response = backgroundLogic.deleteContainer(m.message.userContextId);
|
||||||
|
|
|
@ -1,39 +1,23 @@
|
||||||
|
|
||||||
function requestPermissions() {
|
async function requestPermissions() {
|
||||||
const checkbox = document.querySelector("#bookmarksPermissions");
|
const checkbox = document.querySelector("#bookmarksPermissions");
|
||||||
if (checkbox.checked) {
|
if (checkbox.checked) {
|
||||||
browser.permissions.request({permissions: ["bookmarks"]}).
|
const granted = await browser.permissions.request({permissions: ["bookmarks"]});
|
||||||
then((response) => {
|
if (!granted) {
|
||||||
if (response) {
|
|
||||||
browser.runtime.sendMessage({ method: "resetBookmarksContext" });
|
|
||||||
} else {
|
|
||||||
checkbox.checked = false;
|
checkbox.checked = false;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}).
|
|
||||||
catch((err) => {
|
|
||||||
return err.message;
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
browser.permissions.remove({permissions: ["bookmarks"]}).
|
await browser.permissions.remove({permissions: ["bookmarks"]});
|
||||||
then(() => {
|
|
||||||
browser.runtime.sendMessage({ method: "resetBookmarksContext" });
|
|
||||||
}).
|
|
||||||
catch((err) => {
|
|
||||||
return err.message;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
browser.runtime.sendMessage({ method: "resetBookmarksContext" });
|
||||||
}
|
}
|
||||||
|
|
||||||
function restoreOptions() {
|
async function restoreOptions() {
|
||||||
browser.permissions.getAll()
|
const hasPermission = await browser.permissions.contains({permissions: ["bookmarks"]});
|
||||||
.then((permissions) => {
|
if (hasPermission) {
|
||||||
if (permissions.permissions.includes("bookmarks")) {
|
|
||||||
document.querySelector("#bookmarksPermissions").checked = true;
|
document.querySelector("#bookmarksPermissions").checked = true;
|
||||||
}
|
}
|
||||||
}).
|
|
||||||
catch((err) => {
|
|
||||||
return err.message;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,15 @@
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<form>
|
<form>
|
||||||
<input type="checkbox" id="bookmarksPermissions"/>
|
<label>
|
||||||
<label>Enable Bookmark Menus</label>
|
<input type="checkbox" id="bookmarksPermissions">
|
||||||
|
Enable Bookmark Menus
|
||||||
|
</label>
|
||||||
<p>This setting allows you to open a bookmark or folder of bookmarks in a container.</p>
|
<p>This setting allows you to open a bookmark or folder of bookmarks in a container.</p>
|
||||||
</form>
|
</form>
|
||||||
<script src="js/options.js"></script>
|
<script src="js/options.js"></script>
|
||||||
|
|
|
@ -160,7 +160,8 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-footer edit-containers-panel-footer">
|
<div class="panel-footer edit-containers-panel-footer">
|
||||||
<a href="#" id="exit-edit-mode-link" class="exit-edit-mode-link edit-containers-exit-text">Exit Edit Mode</a>
|
<a href="#" id="exit-edit-mode-link" class="exit-edit-mode-link edit-containers-exit-text">
|
||||||
|
<img src="/img/container-arrow.svg"/>Exit Edit Mode</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ module.exports = () => {
|
||||||
getURL: sinon.stub().returns("moz-extension://multi-account-containers/confirm-page.html")
|
getURL: sinon.stub().returns("moz-extension://multi-account-containers/confirm-page.html")
|
||||||
},
|
},
|
||||||
permissions: {
|
permissions: {
|
||||||
getAll: sinon.stub().returns({"permissions": ["bookmarks"]})
|
contains: sinon.stub().returns(true)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue