Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
fca4923
Feat: Setup background scripts and update manifest for Histofy
MitPete Feb 26, 2025
68f826c
Enhance CI/CD, Webpack, SQLite, and Filtering Logic
MitPete Mar 1, 2025
58412fa
Resolve merge conflicts: Keep current feature branch changes
MitPete Mar 1, 2025
b44cdf0
Resolved all merge conflicts, keeping SQLite storage, filtering logic…
MitPete Mar 1, 2025
118e5f5
Trigger GitHub Actions run on develop
MitPete Mar 1, 2025
2cb95b4
Enable GitHub Actions for develop branch
MitPete Mar 1, 2025
a2c04cf
Fix CI: Ignore dist/ in ESLint GitHub Actions
MitPete Mar 1, 2025
c7a64c5
🚀 Fixed history tracking: removed duplicates, added visit count & dom…
MitPete Mar 2, 2025
ef363d8
Add placeholder buttons and empty summary section to HTML
katesawtell Mar 3, 2025
cb3d18e
✨ Refactor: Improved background.js initialization & classification ca…
MitPete Mar 3, 2025
668c541
Implemented navigation bar with active state and dynamic content update
katesawtell Mar 3, 2025
376dc9b
feat: add IndexedDB model caching and fix infinite loading loop
MitPete Mar 4, 2025
0b85ff2
Merge feature/indexeddb-caching into develop - keeping existing popup…
MitPete Mar 4, 2025
2648e75
feat: Integrate React into Firefox extension and update build process
katesawtell Mar 9, 2025
aaea63d
feat: Add landing page & state based view switching
katesawtell Mar 10, 2025
c3d5b98
New frontend home page
divaldez7464 Mar 11, 2025
9b4c39d
added "top 5 websites" and doughnut chart fro website frequency data
katesawtell Mar 11, 2025
3214052
resize doughnut chart so it remains on page
katesawtell Mar 11, 2025
7e01ae6
feat: Bulk update for website categorization dataset and storage
MitPete Mar 19, 2025
8713e00
Update README.md
MitPete Mar 19, 2025
ab491eb
gitignore fix
Mar 19, 2025
ed1aca4
Diegos changes
divaldez7464 Mar 21, 2025
dcd638c
Refactor view components into separate files for better modularity
katesawtell Mar 21, 2025
d082477
connected chart view
katesawtell Mar 22, 2025
8a4a958
Implemented ApexCharts in ChartView and integrate with application flow
katesawtell Mar 22, 2025
8bdaed1
implemented new IntroToRecap view and randomized prompt selection for…
katesawtell Mar 23, 2025
aeca06a
✨ Optimize model loading & embeddings + unify StorageManager batching…
MitPete Mar 25, 2025
9f74df7
Merge branch 'feature/model-load-optimizations' into develop
MitPete Mar 25, 2025
9c1e129
✅ Refined privacyGuard.js with pixelDomains set
MitPete Mar 27, 2025
a5e695b
new setup push to frontend (#17)
katesawtell Mar 27, 2025
6c03bdf
background videos work
katesawtell Mar 27, 2025
6b48d0a
prompts show up
katesawtell Mar 27, 2025
4995a22
fixed some prompts
katesawtell Mar 27, 2025
fd4e161
Feature/background videos (#19)
katesawtell Mar 27, 2025
c9e7006
✨ Add visit duration tracking and RecapSDK for frontend integration
MitPete Mar 27, 2025
2a68f03
🔀 Merge visit duration + HistofySDK into develop
MitPete Mar 27, 2025
dffd5df
animated bg for home page works
katesawtell Mar 27, 2025
69d4820
took out bg that didn't look good, update names of files
katesawtell Mar 27, 2025
2b35ebf
Merge branch 'feature/background-videos' into frontend
katesawtell Mar 27, 2025
8b6a364
changed some file names
katesawtell Mar 28, 2025
6b265ee
Merge branch 'frontend' into develop
katesawtell Mar 28, 2025
b826005
top 3 websites work and updates prompt (#22)
katesawtell Mar 28, 2025
82c6bfb
Refactor getRandomPrompt for dynamic category access and add timeRang…
katesawtell Mar 28, 2025
9e492fd
UI Update
divaldez7464 Mar 28, 2025
97ea455
✨ Add full SDK integration for analytics & debug utilities
MitPete Apr 2, 2025
a8aab73
🧹 Remove dist/ from version control to prevent conflicts
MitPete Apr 2, 2025
5402ee9
🔗 Connect SDK and background data to frontend popup UI
MitPete Apr 5, 2025
937ba45
🎨 Enhance peak hours chart UI with glow, gradient, animation
MitPete Apr 7, 2025
d5333e9
🎨 Enhance peak hours chart UI with glow, gradient, animation (#23)
MitPete Apr 7, 2025
b6a4215
🎨 Add TopCategoriesChart with sorting, emojis, and dark styling
MitPete Apr 8, 2025
29facfd
Merge develop into feature/top-categories-chart
MitPete Apr 8, 2025
a221633
✅ Resolve SlideShow.jsx merge conflict and finalize merge
MitPete Apr 8, 2025
8bc1734
🐛 Fix:Merge coflict resolved
MitPete Apr 8, 2025
bc87796
🎨 UI Polish: Add animated PeakDaysRings and HomeView glowing buttons
MitPete Apr 9, 2025
375eec3
✨ Add JourneyTimelineSlide with animated timeline and staggered events
MitPete Apr 10, 2025
606bc47
take out emojis from buttons, make slide timer 2-5 seconds
katesawtell Apr 11, 2025
00c87ad
✨ AI Activation Flow: orb animation, permission handling, status upda…
MitPete Apr 16, 2025
f8f80c3
✅ Finalize merge: mark bundle.js files as resolved
MitPete Apr 16, 2025
6fd0bae
Fix error from undefined buttonBase and buttonHover in HomeView
katesawtell Apr 17, 2025
8450bca
backend rewrite
tshasan Apr 17, 2025
b1e74c4
removed webpack
tshasan Apr 17, 2025
aed14f8
fix webpack
tshasan Apr 17, 2025
ba793d8
ml integration
tshasan Apr 18, 2025
4aacf27
fix
tshasan Apr 18, 2025
d1ef171
wait for engine
tshasan Apr 18, 2025
32527ac
live classification fix
tshasan Apr 18, 2025
18d62f9
webpack fix
tshasan Apr 18, 2025
d9e1109
No SDK for rn
divaldez7464 Apr 18, 2025
8dacbb2
add backgrounds to slides
katesawtell Apr 18, 2025
a9a4d2a
Finish rebase fixes
tshasan Apr 18, 2025
54ff2f4
sdk update
tshasan Apr 18, 2025
8bf2833
fix
tshasan Apr 18, 2025
f3d5a95
simple ui fix
tshasan Apr 18, 2025
0ed2fe4
frontend fixes
tshasan Apr 18, 2025
79ee0f6
develop2
tshasan Apr 18, 2025
72a91e4
fix
tshasan Apr 18, 2025
1b5eea1
categories show- not sure why (#26)
katesawtell Apr 18, 2025
7648a5b
rewrite.
tshasan Apr 20, 2025
5593a46
more handlers.
tshasan Apr 20, 2025
a27c557
more handlers2
tshasan Apr 20, 2025
f1c2bec
rewrite 3 using dixie
tshasan Apr 20, 2025
23e9607
Dixie.js integration removed getTypedUrlRatio
tshasan Apr 20, 2025
b5aa81e
slight fixes
tshasan Apr 20, 2025
35bd6e9
cleanup
tshasan Apr 21, 2025
655f802
adding new frontend to develop (#27)
katesawtell Apr 24, 2025
e171fed
Unique Website Handler
divaldez7464 Apr 24, 2025
4377746
Updated Handlers, Created config.js
tshasan Apr 24, 2025
31abdec
Added files
tshasan Apr 24, 2025
7d6fa78
Merge branch 'develop2' into fix/develop2
tshasan Apr 24, 2025
214f02d
Merge pull request #28 from Firefox-Recap/fix/develop2
tshasan Apr 24, 2025
83b8d6b
Charts2 (#29)
katesawtell Apr 24, 2025
cb4bd83
backend fixed
tshasan Apr 25, 2025
ce0fe38
added cache
tshasan Apr 25, 2025
c2013bc
Enhance documentation and improve code structure
tshasan Apr 25, 2025
26bad5b
Merge pull request #30 from Firefox-Recap/jsdoc
tshasan Apr 25, 2025
e55a23a
update slides
katesawtell Apr 25, 2025
1088eb2
Correct singular/plural wording and clean top sites list formatting
katesawtell Apr 25, 2025
8586d94
Merge branch 'main' into develop2
tshasan Apr 25, 2025
cd08a93
git hub ci fixes
tshasan Apr 25, 2025
1661aa2
removed .DS_Store
tshasan Apr 25, 2025
c8fedac
Merge branch 'develop2' of github.com:Firefox-Recap/Firefox-Recap int…
tshasan Apr 25, 2025
24f3864
eslint fix
tshasan Apr 25, 2025
e0c51a3
cleanup
tshasan Apr 25, 2025
ce6f88e
Added NSFW blocklist
divaldez7464 Apr 25, 2025
207550d
Window resizer (#34)
katesawtell Apr 25, 2025
3aa0ac3
loading bar
katesawtell Apr 25, 2025
8e100c5
Original Blocklist
divaldez7464 Apr 26, 2025
6ea0436
Enhance blocklist functionality: add NSFW blocklist support and impro…
tshasan Apr 28, 2025
3a2526a
Merge branch 'develop' into feature/blacklist
tshasan Apr 28, 2025
20609a1
config fixes
tshasan Apr 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions src/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,21 @@
*/

import { initDB } from './initdb.js';
import handlers from './handlers/index.js';
// Use named imports for handlers
import {
fetchAndStoreHistory,
getMostVisitedSites,
getLabelCounts,
getCOCounts,
getVisitsPerHour,
getDailyVisitCounts,
getCategoryTrends,
getTransitionPatterns,
getRecencyFrequency,
getUniqueWebsites
// Note: getTimeSpentPerSite is not exported from handlers/index.js, remove if not needed or add it there.
} from './handlers/index.js';
import handlers from './handlers/index.js'; // Keep default import for window assignment if needed

/**
* Initialize the extension’s database on startup.
Expand Down Expand Up @@ -54,10 +68,11 @@ browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
return true;
}

if (action === "getTimeSpentPerSite") {
getTimeSpentPerSite(days, limit).then(sendResponse);
return true;
}
// Note: getTimeSpentPerSite is not defined/imported. Commenting out or implement handler.
// if (action === "getTimeSpentPerSite") {
// getTimeSpentPerSite(days, limit).then(sendResponse);
// return true;
// }

if (action === "getCategoryTrends") {
getCategoryTrends(days).then(sendResponse);
Expand Down
156 changes: 115 additions & 41 deletions src/background/services/blacklist.js
Original file line number Diff line number Diff line change
@@ -1,76 +1,150 @@
// heavily ai generated this file can be optimized a lot
/**
* @fileoverview Manages fetching, processing, and checking against domain blocklists.
* Supports multiple blocklist sources (e.g., OISD full, OISD NSFW) and combines them.
* Provides functionality to check if a given URL's domain should be blocked based on the loaded lists.
*/

import { parse } from 'tldts';
import { OISD_BLOCKLIST_URL } from '../../config';
import {
OISD_BLOCKLIST_URL,
NSFW_OISD_BLOCKLIST_URL,
BLOCKLIST_ENABLED,
NSFW_BLOCKLIST_ENABLED
} from '../../config';

// Internal state
let oisdBlocklist = new Set();
let oisdRegexList = [];
/**
* Combined set of all domains from enabled blocklists.
* @type {Set<string>}
*/
let combinedBlocklist = new Set();
/**
* Flag indicating whether the blocklist(s) have been successfully loaded.
* @type {boolean}
*/
let isBlocklistLoaded = false;
/**
* Promise that resolves when the blocklist loading process is complete.
* Used to prevent multiple concurrent load attempts.
* @type {Promise<{ domains: Set<string> }> | null}
*/
let blocklistLoadPromise = null;

/**
* Load the OISD blocklist (domains) exactly once.
* @returns {Promise<{ domains: Set<string>, regexes: RegExp[] }>}
* Fetches and processes a single blocklist URL.
* Downloads the list, parses it, filters comments/invalid lines,
* normalizes domains, and returns a Set of valid domains.
* @param {string} url The URL to fetch the blocklist from.
* @returns {Promise<Set<string>>} A promise resolving to a Set of domains from the list.
* Returns an empty Set if fetching or processing fails.
*/
async function fetchAndProcessList(url) {
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP Error: ${response.status} for ${url}`);
}
const text = await response.text();
const lines = text.split('\n').map((l) => l.trim());

return new Set(
lines
// Filter out comments, empty lines, etc.
.filter((l) => l && !/^[#!/\s]/.test(l))
// Normalize: lowercase, remove leading wildcards/dots
.map((l) => l.toLowerCase().replace(/^[*.]+/, ''))
// Filter for valid domain-like strings, excluding IPs
.filter(
(domain) =>
/^[a-z0-9.-]+$/.test(domain) && !/^\d+(\.\d+){3}$/.test(domain),
),
);
} catch (err) {
console.error(`[blacklist] Failed to load list from ${url}:`, err);
return new Set(); // Return empty set on error for this list
}
}


/**
* Loads the configured blocklist(s) based on environment variables.
* Ensures lists are fetched and processed only once.
* Merges domains from multiple enabled lists into `combinedBlocklist`.
* @returns {Promise<{ domains: Set<string> }>} A promise that resolves with an object containing the combined set of blocked domains.
* The promise ensures that the loading process completes before resolving.
*/
export function loadBlocklist() {
if (blocklistLoadPromise) return blocklistLoadPromise;
if (isBlocklistLoaded) return Promise.resolve({ domains: oisdBlocklist, regexes: oisdRegexList });
if (isBlocklistLoaded) return Promise.resolve({ domains: combinedBlocklist });

blocklistLoadPromise = (async () => {
const listsToFetch = [];
if (BLOCKLIST_ENABLED) {
listsToFetch.push(fetchAndProcessList(OISD_BLOCKLIST_URL));
}
if (NSFW_BLOCKLIST_ENABLED) {
listsToFetch.push(fetchAndProcessList(NSFW_OISD_BLOCKLIST_URL));
}

// If no lists are enabled, resolve immediately with empty set
if (listsToFetch.length === 0) {
console.warn('[blacklist] No blocklists enabled.');
isBlocklistLoaded = true;
combinedBlocklist = new Set();
return { domains: combinedBlocklist };
}

try {
const response = await fetch(OISD_BLOCKLIST_URL);
if (!response.ok) {
throw new Error(`HTTP Error: ${response.status}`);
}
const text = await response.text();
const lines = text.split('\n').map((l) => l.trim());

oisdBlocklist = new Set(
lines
.filter((l) => l && !/^[#!/\s]/.test(l))
.map((l) => l.toLowerCase().replace(/^[*.]+/, ''))
.filter(
(domain) =>
/^[a-z0-9.-]+$/.test(domain) && !/^\d+(\.\d+){3}$/.test(domain),
),
);
const results = await Promise.all(listsToFetch);
// Combine all fetched sets into one
combinedBlocklist = new Set(results.flatMap(domainSet => [...domainSet]));

console.log(`[blacklist] Loaded ${combinedBlocklist.size} domains.`);
isBlocklistLoaded = true;
return { domains: oisdBlocklist, regexes: oisdRegexList };
return { domains: combinedBlocklist };
} catch (err) {
console.error('[blacklist] load failed', err);
isBlocklistLoaded = false;
oisdBlocklist.clear();
oisdRegexList = [];
blocklistLoadPromise = null;
return { domains: oisdBlocklist, regexes: oisdRegexList };
// This catch might be redundant if fetchAndProcessList handles errors,
// but kept for safety during Promise.all failure.
console.error('[blacklist] load failed during Promise.all:', err);
isBlocklistLoaded = false; // Reset state on major failure
combinedBlocklist.clear();
blocklistLoadPromise = null; // Allow retry on next call
// Return empty set on major failure, but ensure promise resolves
return { domains: new Set() };

}
})();

return blocklistLoadPromise;
}

// Kick off initial load in the background
loadBlocklist();

/**
* Return true if the given URL’s hostname is on the blocklist.
* Waits until the list is loaded before checking.
* @param {string} url
* @returns {Promise<boolean>}
* Checks if the domain (or its parent domains) of a given URL is present in the loaded blocklist.
* It ensures the blocklist is loaded before performing the check.
* Checks exact hostname, root domain, and parent domains.
* Logs blocked domains and the matched rule.
* @param {string} url The URL string to check.
* @returns {Promise<boolean>} A promise resolving to `true` if the URL's domain should be blocked, `false` otherwise.
* Returns `true` if the URL is malformed and cannot be parsed.
*/
export async function shouldBlockDomain(url) {
const { domains, regexes } = await loadBlocklist();
// Ensure the list is loaded (or load attempt finished)
const { domains } = await loadBlocklist();

// If loading failed or no lists enabled, domains set might be empty.
// An empty set means nothing will be blocked.

try {
const { hostname } = new URL(url);
const host = hostname.toLowerCase();

const { domain: root } = parse(host);

// 1) Match against regex rules (currently unused)
for (const rx of regexes) {
if (rx.test(host)) return true;
}
// Commenting out as 'regexes' is not defined
// for (const rx of regexes) {
// if (rx.test(host)) return true;
// }

// 2) Exact hostname match
if (domains.has(host)) return true;
Expand Down
20 changes: 19 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ export const DAYS_MAP = {
};

/**
* URL of the OISD blocklist (domains or regex patterns).
* URL of the OISD blocklist wildcard domains list.
* @constant {string}
*/
export const OISD_BLOCKLIST_URL = 'https://big.oisd.nl/domainswild';

/**
* URL of the NSFW OISD blocklist wildcard domains list.
* @constant {string}
*/
export const NSFW_OISD_BLOCKLIST_URL = 'https://nsfw.oisd.nl/domainswild';

/**
* List of category labels used by the ML classifier and reporting.
* @constant {string[]}
Expand Down Expand Up @@ -64,6 +70,18 @@ export const ML_CACHE_SIMILARITY_THRESHOLD = 0.75;
*/
export const CONCURRENCY_ENABLED = true;

/**
* Enable the main OISD blocklist.
* @constant {boolean}
*/
export const BLOCKLIST_ENABLED = true;

/**
* Enable the NSFW OISD blocklist.
* @constant {boolean}
*/
export const NSFW_BLOCKLIST_ENABLED = false; // Set to true to enable

/**
* Configuration object passed to the ML engine at initialization. look at this link for more information: https://huggingface.co/firefoxrecap/URL-TITLE-classifier
* @constant {Object}
Expand Down
5 changes: 3 additions & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"tabs",
"webNavigation",
"downloads",
"https://big.oisd.nl/*"
"https://big.oisd.nl/*",
"https://nsfw.oisd.nl/*"
],
"optional_permissions": [
"trialML"
Expand All @@ -34,5 +35,5 @@
"web_accessible_resources": [
"recap.html"
],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'; connect-src https://big.oisd.nl blob:;"
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'; connect-src https://big.oisd.nl https://nsfw.osid.nl blob:;"
}
Loading