Given the black&white nature of X-Faces I want to make them blend with my UI colors better by having the white as the "dialog" color, and the black as the "dialog" text color. So I'm trying to apply the following CSS rules (either using userChrome.css
, or using the Stylish extension):
#fromBuddyIconXFace {
image-rendering: -moz-crisp-edges;
color: -moz-DialogText;
background-color: transparent;
}
If -moz-DialogText
is actually green on my system, I'm currently seeing:
while I would like to see:
This has been previously implemented by the Mnenhy extension:
function ReadCSSColor(aoComputedStyle, asColorName, asDefaultValue)
{
let sColor = aoComputedStyle.getPropertyCSSValue(asColorName).cssText;
if (/^rgba\(/.test(sColor))
{
// have rgba values
sColor = sColor.substr(5, sColor.length - 6);
}
else if (/^rgb\(/.test(sColor))
{
// only rgb values, assume opaque
sColor = sColor.substr(4, sColor.length - 5) + ",1";
}
else if (sColor == "transparent")
{
// special value
sColor = "0,0,0,0";
}
else
{
// default: plain opaque white
sColor = asDefaultValue;
}
return sColor;
}
//
// Create data URL for X-Face-PNG
//
let goPNGFace = new PNGFace();
function FaceURL(asFace, aoComputedStyle)
{
UnCompAll(asFace.replace(/[^!-~]/g, "")); // eliminate illegal chars
Gen();
// set colour values:
// #fromBuddyIcon
// {
// color: green;
// color: -moz-rgba(50%, 50%, 50%, 0.5);
// background-color: red;
// background-color: transparent;
// padding: 0 ! important;
// margin: 5px;
// }
// Unfortunately, the alpha channel value of -moz-rgba is retrievable
// only on trunk since about 2007-01-24...
// background; defaults to plain opaque white
let sBackColors = ReadCSSColor(aoComputedStyle, "background-color", "255,255,255,1");
goPNGFace.Color(0, sBackColors);
// foreground; defaults to plain opaque black
let oForeColors = ReadCSSColor(aoComputedStyle, "color", "0,0,0,1");
goPNGFace.Color(1, oForeColors);
return "data:image/png;base64," + btoa(goPNGFace.URL(F));
}