Giter Club home page Giter Club logo

Comments (2)

TheMapSmith avatar TheMapSmith commented on August 18, 2024

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.

TheMapSmith avatar TheMapSmith commented on August 18, 2024

image

from history-extension.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.