Skip to content

Commit 8d7b8aa

Browse files
committed
fix: tab index issue, add batch permission request
1 parent 5915d54 commit 8d7b8aa

File tree

7 files changed

+93
-29
lines changed

7 files changed

+93
-29
lines changed

docs/index.html

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ <h1 class="display-4 fw-bold lh-1 text-body-secondary">
3636
<a href="https://chromewebstore.google.com/detail/quick-access/pomnndfpgmpdpcjinlcihleaehhblchc" class="btn btn-primary btn-lg px-4 me-md-2 fw-bold">
3737
Add to <span id="browser">Chrome</span>
3838
</a>
39+
<a href="https://github.com/programmerg/quick-access/" class="btn btn-light btn-lg px-4 me-md-2 fw-bold">
40+
Get involved
41+
</a>
3942
</div>
4043
</div>
4144
<div class="col-lg-4 offset-lg-1 p-0 overflow-hidden shadow-lg">
@@ -273,7 +276,7 @@ <h3 class="pt-5 mt-5 mb-4 display-6 lh-1 fw-bold"></h3>
273276
<div class="container">
274277
<p class="pb-5">Thanks for trying it! ;)</p>
275278
<p class="pb-1">This is a hobby project for myself, but let's see if it can conquer the world!</p>
276-
<p class="pb-5">Bug reports, improvement ideas, and pull requests are welcome!</p>
279+
<p class="pb-5"><a href="https://github.com/programmerg/quick-access/issues">Bug reports</a>, <a href="https://github.com/programmerg/quick-access/discussions">improvement ideas</a>, and <a href="https://github.com/programmerg/quick-access/pulls">pull requests</a> are welcome!</p>
277280
</div>
278281

279282
<footer class="container">
@@ -317,8 +320,14 @@ <h3 class="pt-5 mt-5 mb-4 display-6 lh-1 fw-bold"></h3>
317320
}
318321

319322
function initDonwloadButton() {
320-
const downloadBtn = document.getElementById('browser')
321-
if (downloadBtn) downloadBtn.innerText = getBrowser();
323+
const downloadBtn = document.getElementById('browser');
324+
const isFirefox = navigator.userAgent.indexOf("Firefox") != -1;
325+
if (downloadBtn) {
326+
downloadBtn.innerText = getBrowser();
327+
downloadBtn.parentElement.href = isFirefox
328+
? 'https://addons.mozilla.org/hu/firefox/addon/quick-access/'
329+
: 'https://chromewebstore.google.com/detail/quick-access/pomnndfpgmpdpcjinlcihleaehhblchc';
330+
}
322331
}
323332

324333
function initModal() {

index.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,3 +1134,31 @@ fieldset {
11341134
#welcomeModal .permissions label {
11351135
margin: 0.5em 0;
11361136
}
1137+
1138+
#about .form-group {
1139+
text-align: center;
1140+
margin-bottom: 20px;
1141+
}
1142+
1143+
#about h1 {
1144+
display: flex;
1145+
align-items: center;
1146+
justify-content: center;
1147+
gap: 5px;
1148+
}
1149+
1150+
.about-buttons {
1151+
display: grid;
1152+
gap: 15px;
1153+
grid-template-columns: repeat(2, 1fr);
1154+
}
1155+
1156+
.about-buttons a {
1157+
display: block;
1158+
padding: 0.5rem 1rem;
1159+
border-radius: var(--border-radius-lg);
1160+
background-color: var(--color-overlay);
1161+
color: var(--color-text);
1162+
text-align: center;
1163+
text-decoration: none;
1164+
}

index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ <h2 class="modal-title">
113113
<p data-i18n="welcome_permissions2"></p>
114114
<p data-i18n="welcome_footnote"></p>
115115
</div>
116+
117+
<div class="modal-footer">
118+
<!-- button type="reset" class="btn-secondary" data-i18n="cancel"></button -->
119+
<button type="submit" class="btn-primary" style="width:100%" data-i18n="save"></button>
120+
</div>
116121
</form>
117122
</dialog>
118123

index.js

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,28 @@ export class UI {
6464

6565
// MARK: Permissions
6666
registerPermissionEventListeners() {
67-
['topSites', 'history', 'bookmarks', 'tabGroups', 'readingList'].forEach(view => {
68-
const inputs = document.querySelectorAll(`input[name="${view}Permission"]`);
69-
Array.from(inputs).forEach(input => input.addEventListener('change', (e) => {
70-
const items = (view === 'tabGroups') ? ['tabGroups', 'tabs'] : [view];
71-
if (e.target.checked) Permission.request(items).catch(e => this.addToast(e));
72-
else Permission.remove(items).catch(e => this.addToast(e));
73-
}));
67+
['welcomeModal', 'settingsModal'].forEach(id => {
68+
const modal = document.getElementById(id);
69+
const form = modal.querySelector('form');
70+
modal.querySelector('button[type="submit"]').addEventListener('click', (e) => {
71+
const removedItems = [], requestedItems = [];
72+
['topSites', 'history', 'bookmarks', 'tabGroups', 'readingList'].forEach(view => {
73+
const items = (view === 'tabGroups') ? ['tabGroups', 'tabs'] : [view];
74+
if (form[view + 'Permission'].checked) requestedItems.push(...items);
75+
else removedItems.push(...items);
76+
});
77+
78+
if (removedItems.length > 0) {
79+
Permission.remove(removedItems)
80+
.catch(e => this.addToast(e));
81+
}
82+
if (requestedItems.length > 0) {
83+
Permission.request(requestedItems)
84+
.then(granted => { if (!granted) this.handlePermissionChange(); })
85+
.catch(e => this.addToast(e));
86+
}
87+
if (id === 'welcomeModal') modal.close();
88+
});
7489
});
7590

7691
browser.permissions?.onAdded.addListener(({permissions}) => this.handlePermissionChange());
@@ -87,6 +102,8 @@ export class UI {
87102
const btn = document.querySelector(`[data-view="${view}"]`);
88103
btn.classList.toggle('hidden', !permissions.includes(view));
89104
});
105+
106+
if (this.currentView !== '' && !permissions.includes(this.currentView)) this.switchView('');
90107
}
91108

92109
// MARK: Translation
@@ -428,10 +445,11 @@ export class UI {
428445
const parentId = e.currentTarget.dataset.id;
429446
if (tile.classList.contains('folder') && itemId !== parentId) {
430447
if (!(item instanceof Tab && item.url === '')) {
431-
item.save({ parentId: parentId }).catch(e => this.addToast(e)); // move
448+
item.save({ parentId }).catch(e => this.addToast(e)); // move
432449
}
433450
} else if (sourceIdx !== targetIdx) {
434-
item.save({ index: targetIdx }).catch(e => this.addToast(e)); // reorder
451+
const index = items[targetIdx].index;
452+
if (index) item.save({ index }).catch(e => this.addToast(e)); // reorder
435453
}
436454
tile.classList.remove('dropping');
437455
sourceElement.style.opacity = 1;
@@ -462,8 +480,7 @@ export class UI {
462480
}
463481
return;
464482
}
465-
return this.loadContent();
466-
483+
/*
467484
const grid = document.getElementById('grid');
468485
const oldTile = grid.querySelector(`.tile[data-id="${id}"]`);
469486
const newTile = item ? this.createTile(item) : null;
@@ -498,6 +515,8 @@ export class UI {
498515
} else { // propably just moved to another folder, so we can remove the tile from here
499516
if (oldTile) oldTile.remove();
500517
}
518+
*/
519+
return this.loadContent();
501520
}
502521

503522
registerTileEventListeners() {
@@ -857,18 +876,21 @@ export class UI {
857876

858877
const manifest = browser.runtime?.getManifest();
859878
modal.querySelector('#about').innerHTML = `
860-
<div class="form-group" style="text-align: center">
861-
<h2><span>${manifest.name}</span> - <span>${manifest.version}</span></h2>
879+
<div class="form-group">
880+
<h1><img src="./images/icon-24.png" alt="logo"> <span style="color: #5f6368;">${manifest.name}</span></h1>
881+
<p>${browser.i18n?.getMessage('version')}: <span>${manifest.version}</span></p>
862882
</div>
863-
<div class="form-group" style="text-align: center">
883+
<div class="form-group">
864884
<p><span>${manifest.description}</span></p>
865885
</div>
866-
<div class="form-group" style="text-align: center">
886+
<div class="form-group">
867887
<p>${browser.i18n?.getMessage('developer')}: <span>${manifest.author}</span></p>
868888
</div>
869-
<div class="form-group" style="text-align: center">
870-
<p><a href="${manifest.homepage_url}" target="_blank">${browser.i18n?.getMessage('homepage')}</a></p>
871-
<p><a href="https://chromewebstore.google.com/detail/quick-access/pomnndfpgmpdpcjinlcihleaehhblchc" target="_blank">Chrome Web Store</a></p>
889+
<div class="form-group about-buttons">
890+
<a href="${manifest.homepage_url}" target="_blank">${browser.i18n?.getMessage('homepage')}</a>
891+
<a href="https://github.com/programmerg/quick-access/" target="_blank">GitHub</a>
892+
<a href="https://chromewebstore.google.com/detail/quick-access/pomnndfpgmpdpcjinlcihleaehhblchc" target="_blank">Chrome Web Store</a>
893+
<a href="https://addons.mozilla.org/hu/firefox/addon/quick-access/" target="_blank">Firefox Add-ons</a>
872894
</div>
873895
`;
874896
}

manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"minimum_chrome_version": "121",
44
"name": "__MSG_app_name__",
55
"description": "__MSG_app_description__",
6-
"version": "1.4.2",
6+
"version": "1.4.3",
77
"author": "Gelencsér Gergő",
88
"homepage_url": "https://programmerg.github.io/quick-access/",
99
"default_locale": "en",
@@ -31,7 +31,7 @@
3131
],
3232
"browser_specific_settings": {
3333
"gecko": {
34-
"id": "quick-access@programmerg.github.io"
34+
"id": "@quick-access.programmerg.github.io"
3535
}
3636
},
3737
"background": {

readme.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ This is a hobby project for myself, but let's see if it can conquer the world!
3737

3838
## Installation
3939

40-
Get it from the [Chrome Webstore](https://chromewebstore.google.com/detail/quick-access/pomnndfpgmpdpcjinlcihleaehhblchc)
40+
Get it from the [Chrome Web Store](https://chromewebstore.google.com/detail/quick-access/pomnndfpgmpdpcjinlcihleaehhblchc) / [Firefox Add-ons](https://addons.mozilla.org/hu/firefox/addon/quick-access/)
4141

4242
-- OR --
4343

44-
1. Download the <a href="https://github.com/programmerg/quick-access/archive/refs/tags/v1.4.1.zip">latest release</a>.
44+
1. Download the <a href="https://github.com/programmerg/quick-access/archive/refs/tags/v1.4.3.zip">latest release</a>.
4545
2. Open your browser and go to `chrome://extensions`.
4646
3. Enable "Developer mode".
4747
4. Click "Load unpacked" and select the project folder.
48-
5. Hooray, you now have your own Quick Access version!
48+
5. Hooray, you now have your own Quick Access!
4949

5050
## File Structure
5151

@@ -60,7 +60,9 @@ Get it from the [Chrome Webstore](https://chromewebstore.google.com/detail/quick
6060

6161
## Contributing
6262

63-
Bug reports, improvement ideas, and pull requests are welcome!
63+
[Bug reports](https://github.com/programmerg/quick-access/issues),
64+
[improvement ideas](https://github.com/programmerg/quick-access/discussions),
65+
and [pull requests](https://github.com/programmerg/quick-access/pulls) are welcome!
6466

6567
## License
6668

src/Tab.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ export class Tab {
5959
const currentWindow = browser.windows?.WINDOW_ID_CURRENT;
6060
let results = [];
6161

62-
// console.log(await browser.tabs?.query({ windowId: currentWindow })); // TODO: index bug
63-
6462
if (parentId === '') {
6563
const tabGroups = await browser.tabGroups?.query({ windowId: currentWindow });
6664
const tabs = await browser.tabs?.query({ windowId: currentWindow, groupId: -1 });

0 commit comments

Comments
 (0)