Open shaoran opened 4 years ago
Off the top of my head, this issue can occur if one of the tiles' screenshots' heights is short. Likely due to a screenshot of one of your sites being taken at a time when the browser window was shorter than usual.
Fauxbar then sets the inline CSS at runtime to match the shortest screenshot's height for all tiles.
To resolve for now, just tested the code below – will clear the HTML5 persistent data where the thumbnails are stored.
Steps:
Console
tab.// Get the HTML5 file system
window.requestFileSystem(window.PERSISTENT, 50*1024*1024, function(fs){
// Get the `thumbs` directory
fs.root.getDirectory('thumbs', {create:true}, function(dirEntry) {
// Remove the `thumbs` directory and every thumbnail file within
dirEntry.removeRecursively(function(){
// Recreate the `thumbs` directory
fs.root.getDirectory('thumbs', {create:true}, function(newDirEntry) {
console.log("Done.");
}, fileErrorHandler);
}, fileErrorHandler)
}, fileErrorHandler);
}, fileErrorHandler);
Done.
.To implement later:
Oh, very nice, the snippet removed the thumbnails.
One of my tiles points to http://localhost:3000 which is where I usually run my rails and webpack development pages. I usually start this pages with an open dev-tools and I like to have my dev-tools below the site (not on the side) and that's probably why the browser window is shorter than usual when the screenshots are being taken. That would explain why the sizes suddenly change after clicking on a tile.
What is the thumbnail update heuristic that you use? I noticed that for some tiles the screenshots are constantly being updated every time I visit the pages, but this is not the case for other tiles. I haven't been able to determine a pattern here.
Anyway it would be nice to have a button to automatically flush the thumbnails or allow users to set a fixed height for all tiles.
Ah yes, a smaller viewport with DevTools open sounds like the culprit.
Going down the rabbit hole of when Fauxbar decides to take a screenshot...
In background-new.js, there's a captureScreenshot
function, which is called when a tab is loaded and Fauxbar sends itself a chrome.runtime message of either "scrolltop is 0"
or "process prerendered page"
.
// Background event page listens for requests...
chrome.runtime.onMessage.addListener(function(request, sender){
// Generate top site tile thumbnail for page if page reports page has not been scrolled at all
if (request == "scrolltop is 0") {
captureScreenshot(sender);
}
// Pre-rendered page is being navigated to, so let's process it in a moment
else if (request == "process prerendered page") {
// Tab ID changes with prerendering (even though it's the same tab...), so need to get new ID via getSelected()
setTimeout(function(){
chrome.tabs.getSelected(null, function(tab){
processUpdatedTab(tab.id, tab);
captureScreenshot(sender);
});
}, 500);
}
getscrolltop.js:
// If page hasn't been scrolled at all, tell background to possibly create a thumbnail of the page
if (($("body").scrollTop() <= 0 || window.location.hash) && (!window.fauxbar_thumbdone || window.fauxbar_thumbdone != window.document.title)) {
window.fauxbar_thumbdone = window.document.title;
chrome.runtime.sendMessage(null, "scrolltop is 0");
}
The idea is that Fauxbar captures a screenshot once a page has finished loading, but attempts to also take into account Ajax loading (since some webpages are considered "done" loading, but then really they have to wait for JavaScript-heavy post-load operations for content to appear, so that's where the 500
millisecond delay is attempted to be used above with setTimeout
. And attempts to juggle title-changes too.
But if you've scrolled the page down when Fauxbar decides to consider screenshotting or not, Fauxbar won't bother capturing since I assume people would prefer having thumbnails display the top of a page, rather than a screenshot of the page half-way down.
On the Tiles section of the settings, I have Show my top sites as tiles activated with infinate rows x 5 columns.
Usually the tiles have the same height and look OK, but then suddenly when I click on the New Tab or press ctrl+N to open a new tab, the tiles get vertically squashed. Even after a restart of Chrome the tiles remains squashed.
I don't know how to reproduce it, but sometimes it remains like that for days and then suddenly the height gets back to normal.
Inspecting the HTML with the dev tool reveals the following HTML code:
The class
thumb
has a height of132px
, but as you can see the<div class="thumb">
tag has an inline style that overrides the height to44px
.Why is that? How can I fix it?
I'm using Fauxbar version 1.8.1 on a Chrome Version 77.0.3865.120 (on Debian Linux).