Skip to content

Instantly share code, notes, and snippets.

View MariusBongarts's full-sized avatar

Marius Bongarts MariusBongarts

View GitHub Profile
{
"compilerOptions": {
...
"types": ["chrome", "@types/chrome"]
},
}
const path = require("path");
const config = require("./webpack.config");
module.exports = {
...config,
mode: "development",
devServer: {
static: {
directory: path.join(__dirname, "extension"),
},
{
"name": "chrome-history-extension",
...
"permissions": ["history"]
}
{
"name": "chrome-history-extension",
...
"scripts": {
"start": "webpack serve --config webpack.dev.js",
"build": "webpack",
},
...
}
{
"name": "chrome-history-extension",
...
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
},
...
}
{
"action": {
"default_title": "Chrome History Dashboard",
"default_popup": "./index.html",
"default_icon": {
"16": "images/icon16.png", // optional
"24": "images/icon24.png", // optional
"32": "images/icon32.png" // optional
},
}
export const History: React.FC<HistoryProps> = ({ items }) => {
return (
<StyledList>
{items.map((item) => (
<HistoryItem key={item.id} item={item} />
))}
</StyledList>
);
};
const StyledList = styled.ul`
list-style: none;
padding: 0;
margin: 0;
`;
import React from "react";
import { useChromeHistorySearch } from "../hooks/useChromeHistorySearch";
import { History } from "./History";
interface DashboardProps {}
const query = { text: "", maxResults: 100 };
export const Dashboard: React.FC<DashboardProps> = () => {
const mostRecentItems = useChromeHistorySearch(query);
import React from "react";
interface HistoryItemProps {
item: chrome.history.HistoryItem;
}
export const HistoryItem: React.FC<HistoryItemProps> = ({ item }) => {
return (
<li>
<span>{new Date(item.lastVisitTime ?? 0).toLocaleTimeString()}</span>