Skip to content

Commit

Permalink
Invert dark favicons (Croydon#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmktomato committed Dec 16, 2018
1 parent fcc44d4 commit 2fc0bd2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions data/theme/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,7 @@ body
image-rendering: -moz-crisp-edges;
}
}

.invert {
filter: invert(1);
}
2 changes: 2 additions & 0 deletions lib/fast-average-color-4.2.0.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,21 @@ let VerticalTabsReloaded = class VerticalTabsReloaded

if(tabElement.getAttribute("status") != "loading")
{
document.getElementById("tab-icon-" + tabID).setAttribute("src", value);
const imgEl = document.getElementById("tab-icon-" + tabID);
imgEl.setAttribute("src", value);

const theme = this.preferences("theme");
if(theme === "dark" || theme === "darwin")
{
const fac = new FastAverageColor();
fac.getColorAsync(imgEl, (color) => {
if(color.isDark)
{
imgEl.classList.add("invert");
}
fac.destroy();
});
}
}

log.debug("status: " + tabElement.getAttribute("status"));
Expand Down
1 change: 1 addition & 0 deletions vtr.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

<script src="lib/browser-polyfill.js"></script>
<script src="lib/arrive.js"></script>
<script src="lib/fast-average-color-4.2.0.min.js"></script>
<script src="utils/namespace-sidebar.js"></script>
<script src="utils/log.js"></script>
<script src="utils/options.js"></script>
Expand Down

0 comments on commit 2fc0bd2

Please sign in to comment.