krz/crumb
A local alternative to your browser's history.
clone: git clone https://gitbay.org/krz/crumb.git
main: crumb_extension/background.js · raw
1chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
2 if (changeInfo.status !== 'complete' || !tab.url.startsWith("http")) return;
3
4 const url = new URL(tab.url);
5
6 const payload = {
7 title: tab.title,
8 url: tab.url,
9 hostname: url.hostname,
10 path: url.pathname,
11 query: url.search,
12 tabId: tab.id,
13 windowId: tab.windowId,
14 favIconUrl: tab.favIconUrl || null
15 };
16
17 console.log("Crumb: Sending payload", payload);
18
19 fetch("http://localhost:3555", {
20 method: "POST",
21 headers: { "Content-Type": "application/json" },
22 body: JSON.stringify(payload)
23 }).catch(err => {
24 console.error("Crumb: Failed to reach server", err);
25 });
26});