Comments (2)
Sure! To display the favicon between the visit time and the page title, you can update the history_window.js file to include an img element for the favicon.
Here's the updated history_window.js file:
const datePicker = document.getElementById('custom-date-picker');
const historyList = document.getElementById('custom-history-list');
const closeButton = document.getElementById('close-button');
datePicker.addEventListener('change', (event) => {
const selectedDate = event.target.value;
filterHistoryEntriesByDate(selectedDate);
});
closeButton.addEventListener('click', () => {
window.close();
});
function filterHistoryEntriesByDate(selectedDate) {
chrome.history.search({
text: '',
startTime: new Date(selectedDate).getTime(),
endTime: new Date(selectedDate).getTime() + 86400000,
maxResults: 1000
}, (results) => {
historyList.innerHTML = '';
for (const entry of results) {
const entryElement = document.createElement('div');
entryElement.classList.add('entry');
// Format the visited time
const visitedTime = new Date(entry.lastVisitTime);
const timeString = visitedTime.toLocaleTimeString();
// Create a span element to display the visited time
const visitedTimeElement = document.createElement('span');
visitedTimeElement.textContent = `${timeString} - `;
entryElement.appendChild(visitedTimeElement);
// Create an img element for the favicon
const faviconElement = document.createElement('img');
faviconElement.src = `https://s2.googleusercontent.com/s2/favicons?domain=${entry.url}`;
faviconElement.alt = '';
faviconElement.classList.add('favicon');
entryElement.appendChild(faviconElement);
const entryTitle = document.createElement('a');
entryTitle.href = entry.url;
entryTitle.target = '_blank';
entryTitle.textContent = entry.title || entry.url;
entryElement.appendChild(entryTitle);
historyList.appendChild(entryElement);
}
});
}
In this updated file, we added a new faviconElement that is an img element to display the favicon. The src attribute of the faviconElement fetches the favicon from the Google favicon service using the domain of the entry URL. The faviconElement is then appended to the entryElement between the visited time and the page title.
To ensure proper spacing and alignment of the favicon, add the following CSS rule to your style.css file:
.favicon {
display: inline-block;
width: 16px;
height: 16px;
margin-right: 4px;
vertical-align: middle;
}
from history-extension.
from history-extension.
Related Issues (20)
- Spec & Getting Started HOT 2
- New "Popup" Version HOT 1
- Create Icon with Dalle HOT 2
- Use Manifest v3 HOT 1
- Persistent Modal HOT 6
- Add visit time to listing HOT 2
- Add Readme HOT 1
- Linger Time? HOT 2
- Add more details to modal homepage HOT 2
- Date Sorting Issue HOT 10
- time not sorted correctly - time zones? HOT 3
- Limit Duplicated Entries HOT 3
- Start and End Time Display at Top HOT 3
- List of Enhancements HOT 2
- Update Readme
- refactor large filterHistoryEntriesByDate() HOT 5
- Date off-by-one HOT 6
- Earliest and Latest Time Switched HOT 5
- Revise Time Treatment HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from history-extension.