Skip to content

Commit

Permalink
feat/chore: overhaul options page
Browse files Browse the repository at this point in the history
feat: add 2 extra multi-open parameters
  • Loading branch information
igorlogius committed Jul 29, 2024
1 parent e47c033 commit ca67514
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 149 deletions.
27 changes: 23 additions & 4 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ let historyCleanUpQueue = [];
let containerCleanupTimer = null;
let toolbarAction = "";
let deldelay = 30000; // delay until Tmp Containers and History Entries are removed
let multiopen = 3;
let multiopen = 2;
let multiopen2 = 3;
let multiopen3 = 4;
let regexList = null;
let neverOpenInTempContainerRegexList = null;

Expand Down Expand Up @@ -249,7 +251,9 @@ async function onStorageChange() {
if (usecolors.length < 1) {
usecolors = allcolors;
}
multiopen = await getFromStorage("number", "multiopen", 3);
multiopen = await getFromStorage("number", "multiopen", 2);
multiopen2 = await getFromStorage("number", "multiopen2", 3);
multiopen3 = await getFromStorage("number", "multiopen3", 4);

listmode = await getFromStorage("string", "listmode", "include");

Expand Down Expand Up @@ -302,11 +306,26 @@ async function onCommand(command) {
}
}

if (command === "multiopen") {
if (command.startsWith("multiopen")) {
let repeat = 0;

switch (command) {
case "multiopen":
repeat = multiopen;
break;
case "multiopen2":
repeat = multiopen2;
break;
case "multiopen3":
repeat = multiopen3;
break;
default:
return;
}
let tabs = await browser.tabs.query({ currentWindow: true, active: true });
if (tabs.length > 0) {
const atab = tabs[0];
for (let i = 0; i < multiopen; i++) {
for (let i = 0; i < repeat; i++) {
createTempContainerTab(atab.url);
}
}
Expand Down
12 changes: 9 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"commands": {
"_execute_browser_action": {
"description": "Toolbar button action"
"description": "Toolbar Action"
},
"opennewtab": {
"description": "Open newtab in temp container"
Expand All @@ -24,7 +24,13 @@
"description": "Open newtab in same container as current tab"
},
"multiopen": {
"description": "Multi-Open current tab url in N temp container tabs"
"description": "Open current tab URL in X TC tabs"
},
"multiopen2": {
"description": "Open current tab URL in Y TC tabs"
},
"multiopen3": {
"description": "Open current tab URL in Z TC tabs"
}
},
"description": "Open the page,tab,link or bookmark in a new temporary container tab",
Expand All @@ -46,5 +52,5 @@
"tabs"
],
"optional_permissions": ["bookmarks", "history"],
"version": "1.1.38"
"version": "1.1.39"
}
238 changes: 131 additions & 107 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,147 +5,171 @@
body {
background-color: lightgrey;
padding: 5px;
min-height: 640px;
}
textarea {
width: 100%;
height: 15vh;
}
fieldset {
padding: 10px;
}
#permissions {
width: 100%;
}

#permissions td {
border-bottom: 1px solid gray;
margin: 5px;
border: 1px groove black;
}
</style>
</head>
<body>
<fieldset>
<h4>
<abbr title="see Permissions tab to enable">
Optional permissions for added functionality (?):
<legend>
<abbr title="">
<b>Additional Functionality</b>
</abbr>
</h4>
<table id="permissions">
<tr>
<!--td>
<b>Optional Permission</b>
</td>
<td>
<b> Functionality </b>
</td-->
</tr>
<tr>
<td>
<i>1. "Read and modify bookmarks"</i>
</td>
<td>Adds the bookmark context entry</td>
</tr>
<tr>
<td>
<i>2. "Access browsing history" </i>
</td>
<td>Enables automatic history deletion</td>
</tr>
</table>
</fieldset>
</legend>

<fieldset>
<abbr title="Choose what clicking the toolbar button does">
<b>Toolbar button action (?):</b>
1.
<abbr
title="Grant the 'Read and modify bookmarks' permission in the Permissions tab"
>
Context menu on Bookmarks (?)
</abbr>

<br />
2.
<abbr
title="Grant the 'Access browsing history' permission in the Permissions tab"
>
Automatic history deletion (?)
</abbr>
<select id="toolbarAction">
<option value="reopen">Open current tab URL in a temp container</option>
<option value="newtab">Open a new tab in a temp container</option>
</select>
</fieldset>

<fieldset>
<h4>
<abbr title="Hold CTRL to select or deselect multiple colors">
Container colors (?):</abbr
>
</h4>
<select id="usecolors" multiple style="min-height: 13em; width: 100%">
<option value="blue">blue</option>
<option value="turquoise">turquoise</option>
<option value="green">green</option>
<option value="yellow">yellow</option>
<option value="orange">orange</option>
<option value="red">red</option>
<option value="pink">pink</option>
<option value="purple">purple</option>
</select>
<legend>
<b>Toolbar Action</b>
</legend>

<input type="radio" value="reopen" name="toolbarAction" checked /> Open TC
with current URL
<input type="radio" value="newtab" name="toolbarAction" /> Open TC with
'about:newtab'
</fieldset>

<fieldset>
<button
id="experimentalbtn"
style="float: right; text-align: center; font-size: 0.8em"
title="special options (experimental)"
<legend>
<b>Colors</b>
</legend>
<span style="background-color: blue; color: white"
><input type="checkbox" name="usecolors" value="blue" checked />blue
</span>

<span style="background-color: turquoise"
><input
type="checkbox"
name="usecolors"
value="turquoise"
checked
/>turquoise</span
>

<span style="background-color: green; color: white"
><input type="checkbox" name="usecolors" value="green" checked />green
</span>

<span style="background-color: yellow"
><input type="checkbox" name="usecolors" value="yellow" checked />yellow
</span>

<span style="background-color: orange">
<input type="checkbox" name="usecolors" value="orange" checked />orange
</span>

<span style="background-color: red; color: white">
<input type="checkbox" name="usecolors" value="red" checked />red
</span>

<span style="background-color: pink">
<input type="checkbox" name="usecolors" value="pink" checked />pink
</span>

<span style="background-color: purple; color: white">
<input type="checkbox" name="usecolors" value="purple" checked />
purple</span
>
⚠️
</button>
</fieldset>
<div id="mainForm" accept-charset="utf-8" style="display: none">
<fieldset>
<abbr title="Specify the amounts of tabs that will be opened">
<b>Multi-Open shortcut parameter (?):</b>

<fieldset>
<legend>
<abbr
title="Configure when temp containers should be automatically created/used"
>
<b>Automation Mode (?):</b>
</abbr>
</legend>

<div style="padding-left: 25%; border: 1px solid gray">
<input type="radio" value="include" name="listmode" />
<abbr
title="Only tabs matching any followup expression, will be automatically opened in a temporary container"
>
Explicit (?)
</abbr>
<input type="radio" value="exclude" name="listmode" />
<abbr
title="All tabs will be opened in a temp container, execpt those matching any followup expressions"
>
Implicit (?)
</abbr>
<input type="number" id="multiopen" value="3" min="0" max="10" />
</fieldset>
<fieldset>
<fieldset>
<abbr title="Choose between blacklist or whitelist mode">
<h4>Operation Mode (?):</h4>
</abbr>
<select id="listmode" style="width: 100%; text-align: center">
<option value="include">
Open only URLs matching in temp container
</option>
<option value="exclude">
Open everything not matching in a temp container
</option>
</select>
<br />
<textarea
id="textarea_regexstrs"
placeholder="Enter regular expressions line by line here
</div>

<textarea
id="textarea_regexstrs"
placeholder="Enter exclusions for the selected mode here.
Enter regular expressions line by line
Examples:
^https:\/\/www\.facebook\.com.*
^https:\/\/example\.net.*
^https:\/\/.*\.wikipedia\.org.*
"
></textarea>

<button id="regexstrs_save_btn" style="float: right">Save</button>

<h4>
<abbr
title="Tabs with matching urls will automatically be re-opened outside the temp container isolation"
>
Exclusion Matches (?):</abbr
>
</h4>
<textarea
id="textarea_neveropenintcregexstrs"
placeholder="Enter regular expressions line by line here
></textarea>

<!-- button id="regexstrs_save_btn" style="float: right">Save</button-->
</fieldset>

<fieldset>
<legend>
<abbr
title="Tabs with matching URLs will automatically be re-opened outside the temp container isolation"
>
<b>Exclude from TC (?)</b></abbr
>
</legend>
<textarea
id="textarea_neveropenintcregexstrs"
placeholder="Enter regular expressions line by line here
Examples:
^https:\/\/www\.facebook\.com.*
^https:\/\/example\.net.*
^https:\/\/.*\.wikipedia\.org.*
"
></textarea>

<button id="neveropenintcregexstrs_save_btn" style="float: right">
Save
</button>
</fieldset>
</fieldset>
</div>
></textarea>

<!--button id="neveropenintcregexstrs_save_btn" style="float: right">
Save
</button-->
</fieldset>

<fieldset>
<legend>
<abbr
title="Specify the amounts of tabs that should be opened for each shortcut"
>
<b>Multi-Open Shortcut Parameters (?):</b>
</abbr>
</legend>

X <input type="number" id="multiopen" value="2" min="0" max="99" /> Y
<input type="number" id="multiopen2" value="3" min="0" max="99" /> Z
<input type="number" id="multiopen3" value="4" min="0" max="99" />
</fieldset>

<script src="options.js"></script>
</body>
Loading

0 comments on commit ca67514

Please sign in to comment.