Skip to content

Commit

Permalink
feat: same origing policy option
Browse files Browse the repository at this point in the history
  • Loading branch information
paul authored and igorlogius committed Aug 22, 2024
1 parent f4cddf7 commit 81aeb46
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
5 changes: 4 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ let multiopen2 = 3;
let multiopen3 = 4;
let regexList = null;
let neverOpenInTempContainerRegexList = null;
let containerForSameOrigin = true;

// array of all allowed container colors
const allcolors = [
Expand Down Expand Up @@ -267,6 +268,8 @@ async function onStorageChange() {
"historyCleanUpQueue",
[],
);

containerForSameOrigin = await getFromStorage("boolean", "sameorigin", true);
}

// show the user the options page on first installation
Expand Down Expand Up @@ -370,7 +373,7 @@ async function onBeforeNavigate(details) {

// make links open from containered tabs not open in the same container
// !experimental
if (tabInfo.openerTabId) {
if (tabInfo.openerTabId && containerForSameOrigin) {
const openertabInfo = await browser.tabs.get(tabInfo.openerTabId);
if (openertabInfo.cookieStoreId === tabInfo.cookieStoreId) {
if (!sameOrigin(details.url, openertabInfo.url)) {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@
"tabs"
],
"optional_permissions": ["bookmarks", "history"],
"version": "1.1.40"
"version": "1.1.41"
}
12 changes: 12 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,17 @@
<input type="number" id="multiopen3" value="4" min="0" max="99" />
</fieldset>

<fieldset>
<legend>
<abbr title="Prevent data leakage on crossing web page origin boundaries">
<b>Same-origin policy (?)</b>
</abbr>
</legend>
<span>
<input type="checkbox" id="sameorigin" checked />
<label for="sameorigin">Create another TC for links with different <i>origin</i></label>
</span>
</fieldset>

<script src="options.js"></script>
</body>
2 changes: 1 addition & 1 deletion options.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ browser.storage.local
})
.catch(console.error);

["multiopen", "multiopen2", "multiopen3"].map((id) => {
["multiopen", "multiopen2", "multiopen3", "sameorigin"].map((id) => {
browser.storage.local
.get(id)
.then((obj) => {
Expand Down

0 comments on commit 81aeb46

Please sign in to comment.