machawk1 / Mink

Chrome extension that uses Memento to indicate that a page a user is viewing on the live web has an archived copy and to give the user access to the copy
MIT License
49 stars 3 forks source link

Start Mink logic onCommited instead of once the page is fully loaded #124

Open machawk1 opened 9 years ago

machawk1 commented 9 years ago

The webNavigation API provides a hook to identify when a user had committed to a page, i.e., when loading begins and part of the initial resource has been received. This would be a better hook to start the Mink logic, since the URI is also committed and used as the basis for query to the Memento Aggregator. The current implementation waits document.ready.

machawk1 commented 9 years ago

chrome.webNavigation.onCommitted.addListener fires fine from mink.js, a background script, but the listener in content.js, a content script, never catches the message. The displayUIBasedOnContext() function reside in the content script, so message passing must be used.