Skip to content

Commit

Permalink
Merge pull request #22 from Rayquaza01/feature
Browse files Browse the repository at this point in the history
Merge Feature Branch for 1.2.0
  • Loading branch information
Rayquaza01 authored Jul 27, 2023
2 parents 349e176 + 732d200 commit acc59a3
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 59 deletions.
6 changes: 3 additions & 3 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Building Quick Tab Switcher 1.1.0
# Building Quick Tab Switcher 1.1.1

System details:
* Fedora 38
Expand All @@ -9,15 +9,15 @@ System details:

# Building Complete Extension

The source code is in `./src`. It is written in TypeScript and compiled and bundled using Parcel. "webextension-polyfill-ts" is included from the npm package.
The source code is in `./src`. It is written in TypeScript and compiled and bundled using webpack. "webextension-polyfill" is included from the npm package.

Run
```shell
npm install
npm run build:production
npm run build:extension
```
The built extension will be in `./dist` and the zipped version in `./web-ext-artifacts/quick_tab_switcher-1.1.0.zip`
The built extension will be in `./dist` and the zipped version in `./web-ext-artifacts/quick_tab_switcher-1.1.1.zip`

# Live Testing Version

Expand Down
14 changes: 9 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
v1.0.1 - 2020-10-29
* Convert extension to TypeScript
* Extension now bundled with Parcel
* Fix issue where using the arrow keys would scroll extra
* Moved help page to a PDF
v1.1.1 Changes
<ul>
<li>Fix toolbar icon not changing in dark mode</li>
<li>Added option to automatically use theme based on system preferences (<a href="https://github.com/Rayquaza01/quick-tab-switch/issues/17">#17</a>)</li>
<li>Added option to automatically focus search bar when opening the popup (<a href="https://github.com/Rayquaza01/quick-tab-switch/issues/18">#18</a>)</li>
<li>[Backend] Build script using webpack instead of parcel</li>
</ul>

**Full Changelog**: <a href="https://github.com/Rayquaza01/quick-tab-switch/compare/v1.0.1...v1.1.1">v1.0.1...v1.1.1</a>
70 changes: 34 additions & 36 deletions help.fodt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quick-tab-switcher",
"version": "1.1.0",
"version": "1.2.0",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
10 changes: 9 additions & 1 deletion src/OptionsInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@ export enum Themes {
DARK = "dark"
}

export enum SortModes {
DEFAULT = "default",
LAST_ACCESSED = "lastAccessed"
}

export interface OptionsInterface {
shortcut: string;
searchMode: SearchModes;
caseSensitivity: boolean;
theme: Themes;
showDead: boolean;
maxDead: number;
autofocusSearch: boolean
autofocusSearch: boolean;
sortMode: SortModes;
}

export class Options implements OptionsInterface {
Expand All @@ -27,6 +33,7 @@ export class Options implements OptionsInterface {
showDead: boolean;
maxDead: number;
autofocusSearch: boolean;
sortMode: SortModes;

constructor(obj: Partial<OptionsInterface>) {
this.shortcut = obj.shortcut ?? "Ctrl+Shift+B";
Expand All @@ -36,5 +43,6 @@ export class Options implements OptionsInterface {
this.showDead = obj.showDead ?? false;
this.maxDead = obj.maxDead ?? 5;
this.autofocusSearch = obj.autofocusSearch ?? false;
this.sortMode = obj.sortMode ?? SortModes.DEFAULT;
}
}
Binary file modified src/help.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Quick Tab Switcher",
"version": "1.1.0",
"version": "1.2.0",
"description": "A quick tab switcher for Firefox",
"browser_specific_settings": {
"gecko": {
Expand Down
7 changes: 5 additions & 2 deletions src/options/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require("./index.css");
import browser from "webextension-polyfill";
import { Options, SearchModes, Themes } from "../OptionsInterface";
import { Options, SearchModes, SortModes, Themes } from "../OptionsInterface";

const shortcut = document.querySelector("#shortcut") as HTMLInputElement;
const searchMode = document.querySelector("#searchMode") as HTMLSelectElement;
Expand All @@ -9,6 +9,7 @@ const showDead = document.querySelector("#showDead") as HTMLSelectElement;
const maxDead = document.querySelector("#maxDead") as HTMLInputElement;
const theme = document.querySelector("#theme") as HTMLSelectElement;
const autofocusSearch = document.querySelector("#autofocusSearch") as HTMLSelectElement;
const sortMode = document.querySelector("#sortMode") as HTMLSelectElement;

/** Loads from storage onto page */
async function load() {
Expand All @@ -20,6 +21,7 @@ async function load() {
showDead.value = res.showDead.toString();
maxDead.value = res.maxDead.toString();
autofocusSearch.value = res.autofocusSearch.toString();
sortMode.value = res.sortMode;
}

/** Saves from form on page to storage */
Expand All @@ -31,7 +33,8 @@ function save() {
theme: theme.value as Themes,
showDead: showDead.value === "true",
maxDead: Number(maxDead.value),
autofocusSearch: autofocusSearch.value === "true"
autofocusSearch: autofocusSearch.value === "true",
sortMode: sortMode.value as SortModes
});

browser.storage.local.set(opt);
Expand Down
8 changes: 7 additions & 1 deletion src/options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,19 @@ <h3>Recently Closed Tabs</h3>
</div>
</div>
<h3>UI</h3>
<div>
<div class="option">
Colorscheme:
<select id="theme">
<option value="system">Follow System</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>

Sort Tabs
<select id="sortMode">
<option value="default">Tab Order</option>
<option value="lastAccessed">Last Accessed</option>
</select>
</div>
</body>
</html>
25 changes: 17 additions & 8 deletions src/popup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require("./index.css");
import browser, { Tabs } from "webextension-polyfill";
import { TabElement } from "./TabElement";
import { TabList } from "./TabList";
import { Options, Themes } from "../OptionsInterface";
import { Options, SortModes, Themes } from "../OptionsInterface";

/** List of tabs on the page */
let tabList: TabList;
Expand Down Expand Up @@ -146,23 +146,27 @@ function filter(): void {
}

async function main(): Promise<void> {
// get options
const res = new Options(await browser.storage.local.get());

// hide overlay if in focus
if (document.hasFocus()) {
overlay.style.display = "none";
}

// get tabs
const tabs = await browser.tabs.query({ currentWindow: true });
if (res.sortMode === SortModes.LAST_ACCESSED) {
tabs.sort((a, b) => {
// sort based on last accessed key for tabs
// typecast used since ts says lastAccessed could be undefined,
// but according to the docs, this isn't true!
return (b.lastAccessed as number) - (a.lastAccessed as number);
});
}
// create html elements from tab query
let tabEles = tabs.map(createTabs);

// get options
const res = new Options(await browser.storage.local.get());

if (res.autofocusSearch) {
search.focus();
}

if (res.showDead) {
// get recently closed, with limit or unlimited if maxDead is 0
const recentlyClosed = await browser.sessions.getRecentlyClosed(
Expand Down Expand Up @@ -198,6 +202,11 @@ async function main(): Promise<void> {
}

tabList = new TabList(tabEles, res.searchMode, res.caseSensitivity);

if (res.autofocusSearch) {
search.focus();
tabList.getActive().setActive = false;
}
}

// keyboard event
Expand Down
3 changes: 2 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ module.exports = {
// toType: "dir"
//},
{ from: "node_modules/webextension-polyfill/dist/browser-polyfill.min.js" },
{ from: "node_modules/webextension-polyfill/dist/browser-polyfill.min.js.map" }
{ from: "node_modules/webextension-polyfill/dist/browser-polyfill.min.js.map" },
{ from: "src/help.pdf" }
]
})
],
Expand Down

0 comments on commit acc59a3

Please sign in to comment.