Initial commit
This commit is contained in:
commit
ed45ec1270
13 changed files with 1405 additions and 0 deletions
25
.gitignore
vendored
Normal file
25
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Build artifacts
|
||||||
|
web-ext-artifacts/
|
||||||
|
*.xpi
|
||||||
|
*.zip
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# npm
|
||||||
|
package-lock.json
|
||||||
|
|
||||||
|
# OS files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Editor files
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
373
LICENSE
Normal file
373
LICENSE
Normal file
|
|
@ -0,0 +1,373 @@
|
||||||
|
Mozilla Public License Version 2.0
|
||||||
|
==================================
|
||||||
|
|
||||||
|
1. Definitions
|
||||||
|
--------------
|
||||||
|
|
||||||
|
1.1. "Contributor"
|
||||||
|
means each individual or legal entity that creates, contributes to
|
||||||
|
the creation of, or owns Covered Software.
|
||||||
|
|
||||||
|
1.2. "Contributor Version"
|
||||||
|
means the combination of the Contributions of others (if any) used
|
||||||
|
by a Contributor and that particular Contributor's Contribution.
|
||||||
|
|
||||||
|
1.3. "Contribution"
|
||||||
|
means Covered Software of a particular Contributor.
|
||||||
|
|
||||||
|
1.4. "Covered Software"
|
||||||
|
means Source Code Form to which the initial Contributor has attached
|
||||||
|
the notice in Exhibit A, the Executable Form of such Source Code
|
||||||
|
Form, and Modifications of such Source Code Form, in each case
|
||||||
|
including portions thereof.
|
||||||
|
|
||||||
|
1.5. "Incompatible With Secondary Licenses"
|
||||||
|
means
|
||||||
|
|
||||||
|
(a) that the initial Contributor has attached the notice described
|
||||||
|
in Exhibit B to the Covered Software; or
|
||||||
|
|
||||||
|
(b) that the Covered Software was made available under the terms of
|
||||||
|
version 1.1 or earlier of the License, but not also under the
|
||||||
|
terms of a Secondary License.
|
||||||
|
|
||||||
|
1.6. "Executable Form"
|
||||||
|
means any form of the work other than Source Code Form.
|
||||||
|
|
||||||
|
1.7. "Larger Work"
|
||||||
|
means a work that combines Covered Software with other material, in
|
||||||
|
a separate file or files, that is not Covered Software.
|
||||||
|
|
||||||
|
1.8. "License"
|
||||||
|
means this document.
|
||||||
|
|
||||||
|
1.9. "Licensable"
|
||||||
|
means having the right to grant, to the maximum extent possible,
|
||||||
|
whether at the time of the initial grant or subsequently, any and
|
||||||
|
all of the rights conveyed by this License.
|
||||||
|
|
||||||
|
1.10. "Modifications"
|
||||||
|
means any of the following:
|
||||||
|
|
||||||
|
(a) any file in Source Code Form that results from an addition to,
|
||||||
|
deletion from, or modification of the contents of Covered
|
||||||
|
Software; or
|
||||||
|
|
||||||
|
(b) any new file in Source Code Form that contains any Covered
|
||||||
|
Software.
|
||||||
|
|
||||||
|
1.11. "Patent Claims" of a Contributor
|
||||||
|
means any patent claim(s), including without limitation, method,
|
||||||
|
process, and apparatus claims, in any patent Licensable by such
|
||||||
|
Contributor that would be infringed, but for the grant of the
|
||||||
|
License, by the making, using, selling, offering for sale, having
|
||||||
|
made, import, or transfer of either its Contributions or its
|
||||||
|
Contributor Version.
|
||||||
|
|
||||||
|
1.12. "Secondary License"
|
||||||
|
means either the GNU General Public License, Version 2.0, the GNU
|
||||||
|
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||||
|
Public License, Version 3.0, or any later versions of those
|
||||||
|
licenses.
|
||||||
|
|
||||||
|
1.13. "Source Code Form"
|
||||||
|
means the form of the work preferred for making modifications.
|
||||||
|
|
||||||
|
1.14. "You" (or "Your")
|
||||||
|
means an individual or a legal entity exercising rights under this
|
||||||
|
License. For legal entities, "You" includes any entity that
|
||||||
|
controls, is controlled by, or is under common control with You. For
|
||||||
|
purposes of this definition, "control" means (a) the power, direct
|
||||||
|
or indirect, to cause the direction or management of such entity,
|
||||||
|
whether by contract or otherwise, or (b) ownership of more than
|
||||||
|
fifty percent (50%) of the outstanding shares or beneficial
|
||||||
|
ownership of such entity.
|
||||||
|
|
||||||
|
2. License Grants and Conditions
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
2.1. Grants
|
||||||
|
|
||||||
|
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||||
|
non-exclusive license:
|
||||||
|
|
||||||
|
(a) under intellectual property rights (other than patent or trademark)
|
||||||
|
Licensable by such Contributor to use, reproduce, make available,
|
||||||
|
modify, display, perform, distribute, and otherwise exploit its
|
||||||
|
Contributions, either on an unmodified basis, with Modifications, or
|
||||||
|
as part of a Larger Work; and
|
||||||
|
|
||||||
|
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||||
|
for sale, have made, import, and otherwise transfer either its
|
||||||
|
Contributions or its Contributor Version.
|
||||||
|
|
||||||
|
2.2. Effective Date
|
||||||
|
|
||||||
|
The licenses granted in Section 2.1 with respect to any Contribution
|
||||||
|
become effective for each Contribution on the date the Contributor first
|
||||||
|
distributes such Contribution.
|
||||||
|
|
||||||
|
2.3. Limitations on Grant Scope
|
||||||
|
|
||||||
|
The licenses granted in this Section 2 are the only rights granted under
|
||||||
|
this License. No additional rights or licenses will be implied from the
|
||||||
|
distribution or licensing of Covered Software under this License.
|
||||||
|
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||||
|
Contributor:
|
||||||
|
|
||||||
|
(a) for any code that a Contributor has removed from Covered Software;
|
||||||
|
or
|
||||||
|
|
||||||
|
(b) for infringements caused by: (i) Your and any other third party's
|
||||||
|
modifications of Covered Software, or (ii) the combination of its
|
||||||
|
Contributions with other software (except as part of its Contributor
|
||||||
|
Version); or
|
||||||
|
|
||||||
|
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||||
|
its Contributions.
|
||||||
|
|
||||||
|
This License does not grant any rights in the trademarks, service marks,
|
||||||
|
or logos of any Contributor (except as may be necessary to comply with
|
||||||
|
the notice requirements in Section 3.4).
|
||||||
|
|
||||||
|
2.4. Subsequent Licenses
|
||||||
|
|
||||||
|
No Contributor makes additional grants as a result of Your choice to
|
||||||
|
distribute the Covered Software under a subsequent version of this
|
||||||
|
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||||
|
permitted under the terms of Section 3.3).
|
||||||
|
|
||||||
|
2.5. Representation
|
||||||
|
|
||||||
|
Each Contributor represents that the Contributor believes its
|
||||||
|
Contributions are its original creation(s) or it has sufficient rights
|
||||||
|
to grant the rights to its Contributions conveyed by this License.
|
||||||
|
|
||||||
|
2.6. Fair Use
|
||||||
|
|
||||||
|
This License is not intended to limit any rights You have under
|
||||||
|
applicable copyright doctrines of fair use, fair dealing, or other
|
||||||
|
equivalents.
|
||||||
|
|
||||||
|
2.7. Conditions
|
||||||
|
|
||||||
|
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||||
|
in Section 2.1.
|
||||||
|
|
||||||
|
3. Responsibilities
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
3.1. Distribution of Source Form
|
||||||
|
|
||||||
|
All distribution of Covered Software in Source Code Form, including any
|
||||||
|
Modifications that You create or to which You contribute, must be under
|
||||||
|
the terms of this License. You must inform recipients that the Source
|
||||||
|
Code Form of the Covered Software is governed by the terms of this
|
||||||
|
License, and how they can obtain a copy of this License. You may not
|
||||||
|
attempt to alter or restrict the recipients' rights in the Source Code
|
||||||
|
Form.
|
||||||
|
|
||||||
|
3.2. Distribution of Executable Form
|
||||||
|
|
||||||
|
If You distribute Covered Software in Executable Form then:
|
||||||
|
|
||||||
|
(a) such Covered Software must also be made available in Source Code
|
||||||
|
Form, as described in Section 3.1, and You must inform recipients of
|
||||||
|
the Executable Form how they can obtain a copy of such Source Code
|
||||||
|
Form by reasonable means in a timely manner, at a charge no more
|
||||||
|
than the cost of distribution to the recipient; and
|
||||||
|
|
||||||
|
(b) You may distribute such Executable Form under the terms of this
|
||||||
|
License, or sublicense it under different terms, provided that the
|
||||||
|
license for the Executable Form does not attempt to limit or alter
|
||||||
|
the recipients' rights in the Source Code Form under this License.
|
||||||
|
|
||||||
|
3.3. Distribution of a Larger Work
|
||||||
|
|
||||||
|
You may create and distribute a Larger Work under terms of Your choice,
|
||||||
|
provided that You also comply with the requirements of this License for
|
||||||
|
the Covered Software. If the Larger Work is a combination of Covered
|
||||||
|
Software with a work governed by one or more Secondary Licenses, and the
|
||||||
|
Covered Software is not Incompatible With Secondary Licenses, this
|
||||||
|
License permits You to additionally distribute such Covered Software
|
||||||
|
under the terms of such Secondary License(s), so that the recipient of
|
||||||
|
the Larger Work may, at their option, further distribute the Covered
|
||||||
|
Software under the terms of either this License or such Secondary
|
||||||
|
License(s).
|
||||||
|
|
||||||
|
3.4. Notices
|
||||||
|
|
||||||
|
You may not remove or alter the substance of any license notices
|
||||||
|
(including copyright notices, patent notices, disclaimers of warranty,
|
||||||
|
or limitations of liability) contained within the Source Code Form of
|
||||||
|
the Covered Software, except that You may alter any license notices to
|
||||||
|
the extent required to remedy known factual inaccuracies.
|
||||||
|
|
||||||
|
3.5. Application of Additional Terms
|
||||||
|
|
||||||
|
You may choose to offer, and to charge a fee for, warranty, support,
|
||||||
|
indemnity or liability obligations to one or more recipients of Covered
|
||||||
|
Software. However, You may do so only on Your own behalf, and not on
|
||||||
|
behalf of any Contributor. You must make it absolutely clear that any
|
||||||
|
such warranty, support, indemnity, or liability obligation is offered by
|
||||||
|
You alone, and You hereby agree to indemnify every Contributor for any
|
||||||
|
liability incurred by such Contributor as a result of warranty, support,
|
||||||
|
indemnity or liability terms You offer. You may include additional
|
||||||
|
disclaimers of warranty and limitations of liability specific to any
|
||||||
|
jurisdiction.
|
||||||
|
|
||||||
|
4. Inability to Comply Due to Statute or Regulation
|
||||||
|
---------------------------------------------------
|
||||||
|
|
||||||
|
If it is impossible for You to comply with any of the terms of this
|
||||||
|
License with respect to some or all of the Covered Software due to
|
||||||
|
statute, judicial order, or regulation then You must: (a) comply with
|
||||||
|
the terms of this License to the maximum extent possible; and (b)
|
||||||
|
describe the limitations and the code they affect. Such description must
|
||||||
|
be placed in a text file included with all distributions of the Covered
|
||||||
|
Software under this License. Except to the extent prohibited by statute
|
||||||
|
or regulation, such description must be sufficiently detailed for a
|
||||||
|
recipient of ordinary skill to be able to understand it.
|
||||||
|
|
||||||
|
5. Termination
|
||||||
|
--------------
|
||||||
|
|
||||||
|
5.1. The rights granted under this License will terminate automatically
|
||||||
|
if You fail to comply with any of its terms. However, if You become
|
||||||
|
compliant, then the rights granted under this License from a particular
|
||||||
|
Contributor are reinstated (a) provisionally, unless and until such
|
||||||
|
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||||
|
ongoing basis, if such Contributor fails to notify You of the
|
||||||
|
non-compliance by some reasonable means prior to 60 days after You have
|
||||||
|
come back into compliance. Moreover, Your grants from a particular
|
||||||
|
Contributor are reinstated on an ongoing basis if such Contributor
|
||||||
|
notifies You of the non-compliance by some reasonable means, this is the
|
||||||
|
first time You have received notice of non-compliance with this License
|
||||||
|
from such Contributor, and You become compliant prior to 30 days after
|
||||||
|
Your receipt of the notice.
|
||||||
|
|
||||||
|
5.2. If You initiate litigation against any entity by asserting a patent
|
||||||
|
infringement claim (excluding declaratory judgment actions,
|
||||||
|
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||||
|
directly or indirectly infringes any patent, then the rights granted to
|
||||||
|
You by any and all Contributors for the Covered Software under Section
|
||||||
|
2.1 of this License shall terminate.
|
||||||
|
|
||||||
|
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||||
|
end user license agreements (excluding distributors and resellers) which
|
||||||
|
have been validly granted by You or Your distributors under this License
|
||||||
|
prior to termination shall survive termination.
|
||||||
|
|
||||||
|
************************************************************************
|
||||||
|
* *
|
||||||
|
* 6. Disclaimer of Warranty *
|
||||||
|
* ------------------------- *
|
||||||
|
* *
|
||||||
|
* Covered Software is provided under this License on an "as is" *
|
||||||
|
* basis, without warranty of any kind, either expressed, implied, or *
|
||||||
|
* statutory, including, without limitation, warranties that the *
|
||||||
|
* Covered Software is free of defects, merchantable, fit for a *
|
||||||
|
* particular purpose or non-infringing. The entire risk as to the *
|
||||||
|
* quality and performance of the Covered Software is with You. *
|
||||||
|
* Should any Covered Software prove defective in any respect, You *
|
||||||
|
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||||
|
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||||
|
* essential part of this License. No use of any Covered Software is *
|
||||||
|
* authorized under this License except under this disclaimer. *
|
||||||
|
* *
|
||||||
|
************************************************************************
|
||||||
|
|
||||||
|
************************************************************************
|
||||||
|
* *
|
||||||
|
* 7. Limitation of Liability *
|
||||||
|
* -------------------------- *
|
||||||
|
* *
|
||||||
|
* Under no circumstances and under no legal theory, whether tort *
|
||||||
|
* (including negligence), contract, or otherwise, shall any *
|
||||||
|
* Contributor, or anyone who distributes Covered Software as *
|
||||||
|
* permitted above, be liable to You for any direct, indirect, *
|
||||||
|
* special, incidental, or consequential damages of any character *
|
||||||
|
* including, without limitation, damages for lost profits, loss of *
|
||||||
|
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||||
|
* and all other commercial damages or losses, even if such party *
|
||||||
|
* shall have been informed of the possibility of such damages. This *
|
||||||
|
* limitation of liability shall not apply to liability for death or *
|
||||||
|
* personal injury resulting from such party's negligence to the *
|
||||||
|
* extent applicable law prohibits such limitation. Some *
|
||||||
|
* jurisdictions do not allow the exclusion or limitation of *
|
||||||
|
* incidental or consequential damages, so this exclusion and *
|
||||||
|
* limitation may not apply to You. *
|
||||||
|
* *
|
||||||
|
************************************************************************
|
||||||
|
|
||||||
|
8. Litigation
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Any litigation relating to this License may be brought only in the
|
||||||
|
courts of a jurisdiction where the defendant maintains its principal
|
||||||
|
place of business and such litigation shall be governed by laws of that
|
||||||
|
jurisdiction, without reference to its conflict-of-law provisions.
|
||||||
|
Nothing in this Section shall prevent a party's ability to bring
|
||||||
|
cross-claims or counter-claims.
|
||||||
|
|
||||||
|
9. Miscellaneous
|
||||||
|
----------------
|
||||||
|
|
||||||
|
This License represents the complete agreement concerning the subject
|
||||||
|
matter hereof. If any provision of this License is held to be
|
||||||
|
unenforceable, such provision shall be reformed only to the extent
|
||||||
|
necessary to make it enforceable. Any law or regulation which provides
|
||||||
|
that the language of a contract shall be construed against the drafter
|
||||||
|
shall not be used to construe this License against a Contributor.
|
||||||
|
|
||||||
|
10. Versions of the License
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
10.1. New Versions
|
||||||
|
|
||||||
|
Mozilla Foundation is the license steward. Except as provided in Section
|
||||||
|
10.3, no one other than the license steward has the right to modify or
|
||||||
|
publish new versions of this License. Each version will be given a
|
||||||
|
distinguishing version number.
|
||||||
|
|
||||||
|
10.2. Effect of New Versions
|
||||||
|
|
||||||
|
You may distribute the Covered Software under the terms of the version
|
||||||
|
of the License under which You originally received the Covered Software,
|
||||||
|
or under the terms of any subsequent version published by the license
|
||||||
|
steward.
|
||||||
|
|
||||||
|
10.3. Modified Versions
|
||||||
|
|
||||||
|
If you create software not governed by this License, and you want to
|
||||||
|
create a new license for such software, you may create and use a
|
||||||
|
modified version of this License if you rename the license and remove
|
||||||
|
any references to the name of the license steward (except to note that
|
||||||
|
such modified license differs from this License).
|
||||||
|
|
||||||
|
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||||
|
Licenses
|
||||||
|
|
||||||
|
If You choose to distribute Source Code Form that is Incompatible With
|
||||||
|
Secondary Licenses under the terms of this version of the License, the
|
||||||
|
notice described in Exhibit B of this License must be attached.
|
||||||
|
|
||||||
|
Exhibit A - Source Code Form License Notice
|
||||||
|
-------------------------------------------
|
||||||
|
|
||||||
|
This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
If it is not possible or desirable to put the notice in a particular
|
||||||
|
file, then You may include the notice in a location (such as a LICENSE
|
||||||
|
file in a relevant directory) where a recipient would be likely to look
|
||||||
|
for such a notice.
|
||||||
|
|
||||||
|
You may add additional accurate notices of copyright ownership.
|
||||||
|
|
||||||
|
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||||
|
---------------------------------------------------------
|
||||||
|
|
||||||
|
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
|
defined by the Mozilla Public License, v. 2.0.
|
||||||
40
README.md
Normal file
40
README.md
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
# Embermarks
|
||||||
|
|
||||||
|
A Firefox extension that surfaces your forgotten bookmarks — the ones you saved but never visit.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### From Firefox Add-ons (recommended)
|
||||||
|
|
||||||
|
[Install from AMO](https://addons.mozilla.org/firefox/addon/embermarks/)
|
||||||
|
|
||||||
|
### Manual Install
|
||||||
|
|
||||||
|
Download the latest `.xpi` from [Releases](https://github.com/gruberb/embermarks/releases) and drag it into Firefox.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **Discover forgotten bookmarks** — Shows bookmarks you've rarely or never visited
|
||||||
|
- **Configurable criteria** — Set maximum visit count and minimum age for "forgotten" status
|
||||||
|
- **Exclude folders** — Keep certain bookmark folders out of suggestions
|
||||||
|
- **Quick actions** — Visit, skip, or delete bookmarks directly from the popup
|
||||||
|
|
||||||
|
## Building from Source
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git clone https://github.com/gruberb/embermarks.git
|
||||||
|
cd embermarks
|
||||||
|
npx web-ext build
|
||||||
|
```
|
||||||
|
|
||||||
|
The extension will be built to `web-ext-artifacts/`.
|
||||||
|
|
||||||
|
To run in development mode:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npx web-ext run
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Mozilla Public License Version 2.0
|
||||||
164
background.js
Normal file
164
background.js
Normal file
|
|
@ -0,0 +1,164 @@
|
||||||
|
// Embermarks - Background Script
|
||||||
|
// Handles bookmark analysis and forgotten bookmark detection
|
||||||
|
|
||||||
|
// Minimum valid timestamp (Jan 1, 2010) - older dates are likely corrupted imports
|
||||||
|
const MIN_VALID_TIMESTAMP = 1262304000000;
|
||||||
|
|
||||||
|
const DEFAULT_SETTINGS = {
|
||||||
|
excludedFolders: [],
|
||||||
|
numBookmarks: 5,
|
||||||
|
maxVisitCount: 2, // Consider "forgotten" if visited 2 or fewer times
|
||||||
|
minAgeDays: 7, // Only show bookmarks older than 7 days
|
||||||
|
};
|
||||||
|
|
||||||
|
// Get user settings
|
||||||
|
async function getSettings() {
|
||||||
|
const result = await browser.storage.local.get("settings");
|
||||||
|
return { ...DEFAULT_SETTINGS, ...result.settings };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save settings
|
||||||
|
async function saveSettings(settings) {
|
||||||
|
await browser.storage.local.set({
|
||||||
|
settings: { ...DEFAULT_SETTINGS, ...settings },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all bookmarks recursively, respecting excluded folders
|
||||||
|
async function getAllBookmarks(excludedFolderIds = []) {
|
||||||
|
const tree = await browser.bookmarks.getTree();
|
||||||
|
const bookmarks = [];
|
||||||
|
|
||||||
|
function traverse(nodes, currentPath = "") {
|
||||||
|
for (const node of nodes) {
|
||||||
|
// Skip excluded folders and their children
|
||||||
|
if (excludedFolderIds.includes(node.id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.url) {
|
||||||
|
// It's a bookmark
|
||||||
|
bookmarks.push({
|
||||||
|
id: node.id,
|
||||||
|
title: node.title || "Untitled",
|
||||||
|
url: node.url,
|
||||||
|
dateAdded: node.dateAdded,
|
||||||
|
path: currentPath,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.children) {
|
||||||
|
const folderName = node.title || "";
|
||||||
|
const newPath = currentPath
|
||||||
|
? `${currentPath} / ${folderName}`
|
||||||
|
: folderName;
|
||||||
|
traverse(node.children, newPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
traverse(tree);
|
||||||
|
return bookmarks;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get visit count for a URL
|
||||||
|
async function getVisitCount(url) {
|
||||||
|
try {
|
||||||
|
const visits = await browser.history.getVisits({ url });
|
||||||
|
return visits.length;
|
||||||
|
} catch (e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get forgotten bookmarks (low visit count, old enough)
|
||||||
|
async function getForgottenBookmarks() {
|
||||||
|
const settings = await getSettings();
|
||||||
|
const bookmarks = await getAllBookmarks(settings.excludedFolders);
|
||||||
|
|
||||||
|
const now = Date.now();
|
||||||
|
const minAgeMs = settings.minAgeDays * 24 * 60 * 60 * 1000;
|
||||||
|
|
||||||
|
// Filter by age and get visit counts
|
||||||
|
const candidates = [];
|
||||||
|
|
||||||
|
for (const bookmark of bookmarks) {
|
||||||
|
// Skip if too new
|
||||||
|
if (bookmark.dateAdded && now - bookmark.dateAdded < minAgeMs) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip non-http(s) URLs
|
||||||
|
if (
|
||||||
|
!bookmark.url.startsWith("http://") &&
|
||||||
|
!bookmark.url.startsWith("https://")
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const visitCount = await getVisitCount(bookmark.url);
|
||||||
|
|
||||||
|
if (visitCount <= settings.maxVisitCount) {
|
||||||
|
// Check if dateAdded is valid (not corrupted/too old)
|
||||||
|
const hasValidDate =
|
||||||
|
bookmark.dateAdded && bookmark.dateAdded >= MIN_VALID_TIMESTAMP;
|
||||||
|
|
||||||
|
candidates.push({
|
||||||
|
...bookmark,
|
||||||
|
visitCount,
|
||||||
|
daysSinceAdded: hasValidDate
|
||||||
|
? Math.floor((now - bookmark.dateAdded) / (24 * 60 * 60 * 1000))
|
||||||
|
: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shuffle and pick random ones
|
||||||
|
const shuffled = candidates.sort(() => Math.random() - 0.5);
|
||||||
|
return shuffled.slice(0, settings.numBookmarks);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all bookmark folders for settings UI
|
||||||
|
async function getBookmarkFolders() {
|
||||||
|
const tree = await browser.bookmarks.getTree();
|
||||||
|
const folders = [];
|
||||||
|
|
||||||
|
function traverse(nodes, depth = 0) {
|
||||||
|
for (const node of nodes) {
|
||||||
|
if (node.children) {
|
||||||
|
folders.push({
|
||||||
|
id: node.id,
|
||||||
|
title: node.title || "Root",
|
||||||
|
depth,
|
||||||
|
});
|
||||||
|
traverse(node.children, depth + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
traverse(tree);
|
||||||
|
return folders;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle messages from popup/newtab/options
|
||||||
|
browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||||
|
switch (message.action) {
|
||||||
|
case "getForgottenBookmarks":
|
||||||
|
return getForgottenBookmarks();
|
||||||
|
|
||||||
|
case "getBookmarkFolders":
|
||||||
|
return getBookmarkFolders();
|
||||||
|
|
||||||
|
case "getSettings":
|
||||||
|
return getSettings();
|
||||||
|
|
||||||
|
case "saveSettings":
|
||||||
|
return saveSettings(message.settings);
|
||||||
|
|
||||||
|
case "deleteBookmark":
|
||||||
|
return browser.bookmarks.remove(message.bookmarkId);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return Promise.resolve(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
31
icons/ember-48.svg
Normal file
31
icons/ember-48.svg
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48">
|
||||||
|
<!-- Outer glow/ember effect -->
|
||||||
|
<ellipse cx="24" cy="38" rx="8" ry="3" fill="#ff6b35" opacity="0.3"/>
|
||||||
|
|
||||||
|
<!-- Main bookmark body with gradient -->
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="emberGrad" x1="0%" y1="100%" x2="0%" y2="0%">
|
||||||
|
<stop offset="0%" stop-color="#ff6b35"/>
|
||||||
|
<stop offset="50%" stop-color="#ff8c42"/>
|
||||||
|
<stop offset="100%" stop-color="#ffd700"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
|
||||||
|
<!-- Bookmark shape -->
|
||||||
|
<path d="M14 8 L14 40 L24 32 L34 40 L34 8 C34 6, 32 4, 30 4 L18 4 C16 4, 14 6, 14 8 Z"
|
||||||
|
fill="url(#emberGrad)"/>
|
||||||
|
|
||||||
|
<!-- Flame wisps rising from top -->
|
||||||
|
<path d="M20 6 Q18 2, 20 0 Q22 3, 21 6" fill="#ffd700" opacity="0.9"/>
|
||||||
|
<path d="M24 5 Q23 0, 25 -2 Q27 1, 25 5" fill="#ffaa00" opacity="0.8"/>
|
||||||
|
<path d="M28 6 Q30 2, 28 0 Q26 3, 27 6" fill="#ffd700" opacity="0.9"/>
|
||||||
|
|
||||||
|
<!-- Inner ember glow -->
|
||||||
|
<path d="M18 12 L18 34 L24 28 L30 34 L30 12 Z"
|
||||||
|
fill="#1a1a1a" opacity="0.2"/>
|
||||||
|
|
||||||
|
<!-- Small ember particles -->
|
||||||
|
<circle cx="12" cy="10" r="1.5" fill="#ffd700" opacity="0.7"/>
|
||||||
|
<circle cx="36" cy="8" r="1" fill="#ff8c42" opacity="0.6"/>
|
||||||
|
<circle cx="10" cy="18" r="1" fill="#ff6b35" opacity="0.5"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.2 KiB |
32
icons/ember-96.svg
Normal file
32
icons/ember-96.svg
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96">
|
||||||
|
<!-- Outer glow/ember effect -->
|
||||||
|
<ellipse cx="48" cy="76" rx="16" ry="6" fill="#ff6b35" opacity="0.3"/>
|
||||||
|
|
||||||
|
<!-- Main bookmark body with gradient -->
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="emberGrad" x1="0%" y1="100%" x2="0%" y2="0%">
|
||||||
|
<stop offset="0%" stop-color="#ff6b35"/>
|
||||||
|
<stop offset="50%" stop-color="#ff8c42"/>
|
||||||
|
<stop offset="100%" stop-color="#ffd700"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
|
||||||
|
<!-- Bookmark shape -->
|
||||||
|
<path d="M28 16 L28 80 L48 64 L68 80 L68 16 C68 12, 64 8, 60 8 L36 8 C32 8, 28 12, 28 16 Z"
|
||||||
|
fill="url(#emberGrad)"/>
|
||||||
|
|
||||||
|
<!-- Flame wisps rising from top -->
|
||||||
|
<path d="M40 12 Q36 4, 40 0 Q44 6, 42 12" fill="#ffd700" opacity="0.9"/>
|
||||||
|
<path d="M48 10 Q46 0, 50 -4 Q54 2, 50 10" fill="#ffaa00" opacity="0.8"/>
|
||||||
|
<path d="M56 12 Q60 4, 56 0 Q52 6, 54 12" fill="#ffd700" opacity="0.9"/>
|
||||||
|
|
||||||
|
<!-- Inner ember glow -->
|
||||||
|
<path d="M36 24 L36 68 L48 56 L60 68 L60 24 Z"
|
||||||
|
fill="#1a1a1a" opacity="0.2"/>
|
||||||
|
|
||||||
|
<!-- Small ember particles -->
|
||||||
|
<circle cx="24" cy="20" r="3" fill="#ffd700" opacity="0.7"/>
|
||||||
|
<circle cx="72" cy="16" r="2" fill="#ff8c42" opacity="0.6"/>
|
||||||
|
<circle cx="20" cy="36" r="2" fill="#ff6b35" opacity="0.5"/>
|
||||||
|
<circle cx="76" cy="28" r="1.5" fill="#ffd700" opacity="0.5"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.3 KiB |
33
manifest.json
Normal file
33
manifest.json
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
{
|
||||||
|
"manifest_version": 2,
|
||||||
|
"name": "Embermarks",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Rediscover your forgotten bookmarks. Surface the ones you never visit.",
|
||||||
|
"author": "Bastian Gruber",
|
||||||
|
"homepage_url": "https://github.com/gruberb/embermarks",
|
||||||
|
|
||||||
|
"icons": {
|
||||||
|
"48": "icons/ember-48.svg",
|
||||||
|
"96": "icons/ember-96.svg"
|
||||||
|
},
|
||||||
|
|
||||||
|
"permissions": ["bookmarks", "history", "storage"],
|
||||||
|
|
||||||
|
"browser_action": {
|
||||||
|
"default_icon": {
|
||||||
|
"48": "icons/ember-48.svg"
|
||||||
|
},
|
||||||
|
"default_title": "Embermarks",
|
||||||
|
"default_popup": "popup/popup.html"
|
||||||
|
},
|
||||||
|
|
||||||
|
"options_ui": {
|
||||||
|
"page": "options/options.html",
|
||||||
|
"browser_style": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"background": {
|
||||||
|
"scripts": ["background.js"],
|
||||||
|
"persistent": false
|
||||||
|
}
|
||||||
|
}
|
||||||
285
options/options.html
Normal file
285
options/options.html
Normal file
|
|
@ -0,0 +1,285 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Embermarks Settings</title>
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--ember-orange: #ff6b35;
|
||||||
|
--ember-gold: #ffd700;
|
||||||
|
--ember-warm: #ff8c42;
|
||||||
|
--ember-dark: #2d2d2d;
|
||||||
|
--ember-gray: #888;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family:
|
||||||
|
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
||||||
|
sans-serif;
|
||||||
|
background: #1a1a1a;
|
||||||
|
color: #fff;
|
||||||
|
min-height: 100vh;
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 1.8rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
background: linear-gradient(
|
||||||
|
90deg,
|
||||||
|
var(--ember-gold),
|
||||||
|
var(--ember-orange)
|
||||||
|
);
|
||||||
|
-webkit-background-clip: text;
|
||||||
|
-webkit-text-fill-color: transparent;
|
||||||
|
background-clip: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-icon {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
vertical-align: middle;
|
||||||
|
margin-right: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
color: var(--ember-gray);
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section {
|
||||||
|
background: var(--ember-dark);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 1.5rem;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section h2 {
|
||||||
|
font-size: 1rem;
|
||||||
|
color: var(--ember-warm);
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setting-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0.75rem 0;
|
||||||
|
border-bottom: 1px solid #444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setting-row:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setting-label {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setting-label span {
|
||||||
|
display: block;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: var(--ember-gray);
|
||||||
|
margin-top: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="number"] {
|
||||||
|
width: 80px;
|
||||||
|
padding: 0.5rem;
|
||||||
|
border: 1px solid #444;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: #1a1a1a;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 1rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="checkbox"] {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
accent-color: var(--ember-orange);
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-list {
|
||||||
|
max-height: 300px;
|
||||||
|
overflow-y: auto;
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
padding: 0.5rem;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-item:hover {
|
||||||
|
background: rgba(255, 140, 66, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-item input {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-item label {
|
||||||
|
flex: 1;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.folder-depth-1 {
|
||||||
|
padding-left: 1.5rem;
|
||||||
|
}
|
||||||
|
.folder-depth-2 {
|
||||||
|
padding-left: 3rem;
|
||||||
|
}
|
||||||
|
.folder-depth-3 {
|
||||||
|
padding-left: 4.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-save {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
padding: 1rem;
|
||||||
|
background: linear-gradient(
|
||||||
|
135deg,
|
||||||
|
var(--ember-orange),
|
||||||
|
var(--ember-warm)
|
||||||
|
);
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: filter 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-save:hover {
|
||||||
|
filter: brightness(1.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.save-status {
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 1rem;
|
||||||
|
color: var(--ember-warm);
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.save-status.visible {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h1>
|
||||||
|
<img
|
||||||
|
src="../icons/ember-48.svg"
|
||||||
|
alt=""
|
||||||
|
class="header-icon"
|
||||||
|
/>Embermarks Settings
|
||||||
|
</h1>
|
||||||
|
<p class="subtitle">
|
||||||
|
Configure how forgotten bookmarks are discovered
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="section">
|
||||||
|
<h2>Display</h2>
|
||||||
|
|
||||||
|
<div class="setting-row">
|
||||||
|
<div class="setting-label">
|
||||||
|
Number of bookmarks to show
|
||||||
|
<span
|
||||||
|
>How many forgotten bookmarks to display at
|
||||||
|
once</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="numBookmarks"
|
||||||
|
min="1"
|
||||||
|
max="20"
|
||||||
|
value="5"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="section">
|
||||||
|
<h2>Forgotten Criteria</h2>
|
||||||
|
|
||||||
|
<div class="setting-row">
|
||||||
|
<div class="setting-label">
|
||||||
|
Maximum visit count
|
||||||
|
<span
|
||||||
|
>Bookmarks with this many visits or fewer are
|
||||||
|
considered "forgotten"</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="maxVisitCount"
|
||||||
|
min="0"
|
||||||
|
max="100"
|
||||||
|
value="2"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-row">
|
||||||
|
<div class="setting-label">
|
||||||
|
Minimum age (days)
|
||||||
|
<span
|
||||||
|
>Only show bookmarks older than this many days</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="minAgeDays"
|
||||||
|
min="0"
|
||||||
|
max="365"
|
||||||
|
value="7"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="section">
|
||||||
|
<h2>Excluded Folders</h2>
|
||||||
|
<p
|
||||||
|
style="
|
||||||
|
color: var(--ember-gray);
|
||||||
|
font-size: 0.9rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
"
|
||||||
|
>
|
||||||
|
Check folders you want to exclude from suggestions
|
||||||
|
</p>
|
||||||
|
<div class="folder-list" id="folderList">
|
||||||
|
<div style="color: var(--ember-gray); padding: 1rem">
|
||||||
|
Loading folders...
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button class="btn-save" id="saveBtn">Save Settings</button>
|
||||||
|
<div class="save-status" id="saveStatus">✓ Settings saved!</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="options.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
64
options/options.js
Normal file
64
options/options.js
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
// Embermarks - Options Script
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", async () => {
|
||||||
|
const numBookmarksInput = document.getElementById("numBookmarks");
|
||||||
|
const maxVisitCountInput = document.getElementById("maxVisitCount");
|
||||||
|
const minAgeDaysInput = document.getElementById("minAgeDays");
|
||||||
|
const folderList = document.getElementById("folderList");
|
||||||
|
const saveBtn = document.getElementById("saveBtn");
|
||||||
|
const saveStatus = document.getElementById("saveStatus");
|
||||||
|
|
||||||
|
// Load current settings
|
||||||
|
const settings = await browser.runtime.sendMessage({ action: "getSettings" });
|
||||||
|
|
||||||
|
numBookmarksInput.value = settings.numBookmarks;
|
||||||
|
maxVisitCountInput.value = settings.maxVisitCount;
|
||||||
|
minAgeDaysInput.value = settings.minAgeDays;
|
||||||
|
|
||||||
|
// Load folder list
|
||||||
|
const folders = await browser.runtime.sendMessage({
|
||||||
|
action: "getBookmarkFolders",
|
||||||
|
});
|
||||||
|
|
||||||
|
folderList.innerHTML = "";
|
||||||
|
|
||||||
|
for (const folder of folders) {
|
||||||
|
const item = document.createElement("div");
|
||||||
|
item.className = `folder-item folder-depth-${Math.min(folder.depth, 3)}`;
|
||||||
|
|
||||||
|
const isExcluded = settings.excludedFolders.includes(folder.id);
|
||||||
|
|
||||||
|
item.innerHTML = `
|
||||||
|
<input type="checkbox" id="folder-${folder.id}" value="${folder.id}" ${isExcluded ? "checked" : ""}>
|
||||||
|
<label for="folder-${folder.id}">📁 ${folder.title || "(unnamed)"}</label>
|
||||||
|
`;
|
||||||
|
|
||||||
|
folderList.appendChild(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save settings
|
||||||
|
saveBtn.addEventListener("click", async () => {
|
||||||
|
const excludedFolders = [];
|
||||||
|
folderList.querySelectorAll("input:checked").forEach((checkbox) => {
|
||||||
|
excludedFolders.push(checkbox.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
const newSettings = {
|
||||||
|
numBookmarks: parseInt(numBookmarksInput.value, 10),
|
||||||
|
maxVisitCount: parseInt(maxVisitCountInput.value, 10),
|
||||||
|
minAgeDays: parseInt(minAgeDaysInput.value, 10),
|
||||||
|
excludedFolders,
|
||||||
|
};
|
||||||
|
|
||||||
|
await browser.runtime.sendMessage({
|
||||||
|
action: "saveSettings",
|
||||||
|
settings: newSettings,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Show save confirmation
|
||||||
|
saveStatus.classList.add("visible");
|
||||||
|
setTimeout(() => {
|
||||||
|
saveStatus.classList.remove("visible");
|
||||||
|
}, 2000);
|
||||||
|
});
|
||||||
|
});
|
||||||
46
popup/popup.html
Normal file
46
popup/popup.html
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>Embermarks</title>
|
||||||
|
<link rel="stylesheet" href="../shared/styles.css" />
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
width: 400px;
|
||||||
|
min-height: 320px;
|
||||||
|
max-height: 540px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-icon {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
vertical-align: middle;
|
||||||
|
margin-right: 5px;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="header">
|
||||||
|
<h1>
|
||||||
|
<img src="../icons/ember-48.svg" alt="" class="header-icon" />
|
||||||
|
Embermarks
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bookmarks-container" id="bookmarks">
|
||||||
|
<div class="loading"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="footer-actions">
|
||||||
|
<button class="footer-btn" id="refresh">Refresh</button>
|
||||||
|
<a href="../options/options.html" class="footer-btn" target="_blank"
|
||||||
|
>Settings</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="../shared/ui.js"></script>
|
||||||
|
<script src="popup.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
14
popup/popup.js
Normal file
14
popup/popup.js
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
// Embermarks - Popup Script
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
|
const container = document.getElementById('bookmarks');
|
||||||
|
const refreshBtn = document.getElementById('refresh');
|
||||||
|
|
||||||
|
// Load bookmarks
|
||||||
|
await loadBookmarks(container);
|
||||||
|
|
||||||
|
// Refresh button
|
||||||
|
refreshBtn.addEventListener('click', async () => {
|
||||||
|
await loadBookmarks(container);
|
||||||
|
});
|
||||||
|
});
|
||||||
182
shared/styles.css
Normal file
182
shared/styles.css
Normal file
|
|
@ -0,0 +1,182 @@
|
||||||
|
/* Embermarks - Shared Styles */
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--bg-primary: #2a2a2a;
|
||||||
|
--bg-card: #333333;
|
||||||
|
--bg-hover: #3a3a3a;
|
||||||
|
--text-primary: #e0e0e0;
|
||||||
|
--text-secondary: #888888;
|
||||||
|
--border-color: #444444;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family:
|
||||||
|
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||||
|
background: var(--bg-primary);
|
||||||
|
color: var(--text-primary);
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Header */
|
||||||
|
.header {
|
||||||
|
text-align: center;
|
||||||
|
padding: 1rem 1rem 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header h1 {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.header p {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Bookmark Cards Container */
|
||||||
|
.bookmarks-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
padding: 0.5rem 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Individual Bookmark Card */
|
||||||
|
.bookmark-card {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
background: var(--bg-card);
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-radius: 8px;
|
||||||
|
text-decoration: none;
|
||||||
|
color: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.1s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmark-card:hover {
|
||||||
|
background: var(--bg-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmark-favicon {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: var(--bg-hover);
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 1rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmark-favicon img {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmark-info {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmark-title {
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--text-primary);
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmark-meta {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
margin-bottom: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bookmark-folder {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
opacity: 0.7;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Empty State */
|
||||||
|
.empty-state {
|
||||||
|
text-align: center;
|
||||||
|
padding: 3rem 1rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state .icon {
|
||||||
|
font-size: 1.75rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state h2 {
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 500;
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state p {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Loading State */
|
||||||
|
.loading {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
padding: 3rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading::after {
|
||||||
|
content: "Loading...";
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Footer Actions */
|
||||||
|
.footer-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 0.75rem;
|
||||||
|
border-top: 1px solid var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-btn {
|
||||||
|
flex: 1;
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
background: var(--bg-card);
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.1s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-btn:hover {
|
||||||
|
background: var(--bg-hover);
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
116
shared/ui.js
Normal file
116
shared/ui.js
Normal file
|
|
@ -0,0 +1,116 @@
|
||||||
|
// Embermarks - Shared UI Logic
|
||||||
|
|
||||||
|
// Get favicon URL for a bookmark
|
||||||
|
function getFaviconUrl(url) {
|
||||||
|
try {
|
||||||
|
const urlObj = new URL(url);
|
||||||
|
return `https://www.google.com/s2/favicons?domain=${urlObj.hostname}&sz=32`;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format days ago
|
||||||
|
function formatDaysAgo(days) {
|
||||||
|
if (days === null) return "Unknown";
|
||||||
|
if (days === 0) return "Today";
|
||||||
|
if (days === 1) return "Yesterday";
|
||||||
|
if (days < 30) return `${days}d ago`;
|
||||||
|
if (days < 365) return `${Math.floor(days / 30)}mo ago`;
|
||||||
|
return `${Math.floor(days / 365)}y ago`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Escape HTML
|
||||||
|
function escapeHtml(text) {
|
||||||
|
const div = document.createElement("div");
|
||||||
|
div.textContent = text;
|
||||||
|
return div.innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a bookmark card element
|
||||||
|
function createBookmarkCard(bookmark) {
|
||||||
|
const card = document.createElement("a");
|
||||||
|
card.className = "bookmark-card";
|
||||||
|
card.href = bookmark.url;
|
||||||
|
card.target = "_blank";
|
||||||
|
card.rel = "noopener";
|
||||||
|
|
||||||
|
const faviconUrl = getFaviconUrl(bookmark.url);
|
||||||
|
|
||||||
|
card.innerHTML = `
|
||||||
|
<div class="bookmark-favicon">
|
||||||
|
${faviconUrl ? `<img src="${faviconUrl}" alt="">` : "🔖"}
|
||||||
|
</div>
|
||||||
|
<div class="bookmark-info">
|
||||||
|
<div class="bookmark-title" title="${escapeHtml(bookmark.title)}">${escapeHtml(bookmark.title)}</div>
|
||||||
|
<div class="bookmark-meta">
|
||||||
|
${bookmark.visitCount} visit${bookmark.visitCount !== 1 ? "s" : ""} · Added ${formatDaysAgo(bookmark.daysSinceAdded)}
|
||||||
|
</div>
|
||||||
|
${bookmark.path ? `<div class="bookmark-folder">${escapeHtml(bookmark.path)}</div>` : ""}
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
return card;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show empty state
|
||||||
|
function showEmptyState(container, reason = "none") {
|
||||||
|
const messages = {
|
||||||
|
none: {
|
||||||
|
icon: "✓",
|
||||||
|
title: "No forgotten bookmarks",
|
||||||
|
text: "You're on top of things!",
|
||||||
|
},
|
||||||
|
allDismissed: {
|
||||||
|
icon: "✓",
|
||||||
|
title: "All caught up",
|
||||||
|
text: "Refresh to see more",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const msg = messages[reason] || messages.none;
|
||||||
|
|
||||||
|
container.innerHTML = `
|
||||||
|
<div class="empty-state">
|
||||||
|
<div class="icon">${msg.icon}</div>
|
||||||
|
<h2>${msg.title}</h2>
|
||||||
|
<p>${msg.text}</p>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show loading state
|
||||||
|
function showLoading(container) {
|
||||||
|
container.innerHTML = '<div class="loading"></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load and display bookmarks
|
||||||
|
async function loadBookmarks(container) {
|
||||||
|
showLoading(container);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const bookmarks = await browser.runtime.sendMessage({
|
||||||
|
action: "getForgottenBookmarks",
|
||||||
|
});
|
||||||
|
|
||||||
|
container.innerHTML = "";
|
||||||
|
|
||||||
|
if (!bookmarks || bookmarks.length === 0) {
|
||||||
|
showEmptyState(container, "none");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const bookmark of bookmarks) {
|
||||||
|
container.appendChild(createBookmarkCard(bookmark));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to load bookmarks:", error);
|
||||||
|
container.innerHTML = `
|
||||||
|
<div class="empty-state">
|
||||||
|
<div class="icon">!</div>
|
||||||
|
<h2>Oops</h2>
|
||||||
|
<p>Failed to load bookmarks</p>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue