ireadit

A browser extension that hides the comment section of link posts on reddit and hacker news if the article has not been read.


ireadit

/

ireadit

/

background.js

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
chrome.runtime.onMessage.addListener(
(req, sender, callback) => {
  if (req.type === 'check_history')
  {
    check_history(req.url, callback);
  }
  else
  {
    return false;
  }
  return true;
});

function check_history(url, callback)
{
  chrome.history.getVisits({url: url}, (items) => {
    var res = {url: false};
    if (items != null && items.length > 0)
    {
      res.url = true;
    }
    callback(res);
  });
}
Back to Top