Announce and Discuss the Latest Theme and Extension Releases.
I created a new Checkbox button and exported the button code to a file (document_colors.but).
You can save the above posted code to a .btn file and import this file in PrefBar.
I didn't know about importing and exporting. There is always something new to learn. Anyway, I had already created a similar button. Now what I want is to combine this and the systemcolors in one.
OK. I found in a backup the old button and exported it. This is it:
"label": "colors ",
"getfunction": "value = goPrefBar.GetPref(\"browser.display.use_document_colors\");",
"setfunction": "goPrefBar.SetPref(\"browser.display.use_system_colors\", !value);\ngoPrefBar.SetPref(\"browser.display.use_document_colors\", value);"
How can I modify the first "getfunction" to apply to the new key? The issue is the line:
To update the Color check box to use the new browser.display.use_document_colors integer behavior, I built a new Menulist rom the Prefbar Customize window. When I exported the button, it looks like this:
"Only with HCT",
Always means Always override the document colors and use my color preferences. Never should be obvious. The Only with HCT is Only override the document colors for pages with high contrast themes. I have vision issues that are improved with a lower contrast theme. I hope this will help others if they want to cut and paste the above into a file. Make sure to add quotes ("filename.btn") to save it with the btn extension. Then select Customize and Import.
After trying my initial solution for a bit, I've modified my PrefBar menulist for browser.display.use_document_colors a bit. I replaced "Always" with "My colors" and "Never" with "Doc. colors". I am considering deleting the HCT line since it's redundant for me. (On all of the sites I look at, the behavior of "Never" and "Only with HCT" are the same.)
HCT for you is similar to your system colors -- and I can not imagine a case in which it wouldn't be, I cannot understand the reasoning of those who introduced this option.
Anyway, personally I prefer a checkbox since it takes less real estate and it takes only 1 click.
And I would like to combine changing document colors with changing system colors since:
1) For System Colors to have effect, the Document Colors should be off
2) When Document colors is on, if foreground color is not specified in the webpage, FF looks first to System colors if it is on, and if not to the FF colors. Since some webpages specify only background (white), and my System foreground is also white, in these cases I want it to look at the FF colors, where the foreground is specified as black, so in these cases the System Colors should be off.
So I need to change both, and preferably with 1 click instead of with 2, as I now do, by clicking the 2 checkboxes (that also take more space).
For the white on white, I just hit <Ctrl>+A and get readable text. For space, I've stacked some of my prefBar buttons by adding a Submenu and dropping several into that folder. That still has the two click problem for you.
Something like this should work:
value = (goPrefBar.GetPref("browser.display.use_document_colors") != 1) ? 1 : 2; // Override: 1:never; 2:always
goPrefBar.SetPref("browser.display.use_system_colors", (value == 2));
value = (goPrefBar.GetPref("browser.display.use_document_colors") == 1);
Last edited by dickvl on May 2nd, 2015, 6:44 pm, edited 1 time in total.
> goPrefBar.SetPref("browser.display.use_system_colors", (value == 2));
Is this correct? Isn't it boolean?
The (value == 2) expression is evaluated as a Boolean: true if value is 2 (always) and false otherwise.
You can keep the about:config page open in a tab to see the prefs change when you click the button.
I found that I needed these two lines in the Set function for the extcheck button. Otherwise it didn't work properly due to the new Firefox 37 settings. I found that rest of dickvl's code works nicely.
value1 = (goPrefBar.GetPref("browser.display.document_color_use") != 1) ? 1 : 2; // 1:never use my colors; 2:always use my colors
Thank you. It's much better than my menulist solution.
I've added in the Set-function a line to change the system colors simultaneously:
value1 = (goPrefBar.GetPref("browser.display.document_color_use") != 1) ? 1 : 2;
while in the Get-function I have:
value = goPrefBar.GetPref("browser.display.document_color_use");
Now when it's checked it uses the document colors and secondarily the FF colors (so I won't encounter the issue of white text on white background). When it's unchecked, it uses the system colors. I've also added a hot key. Though I am not sure I understand how the Get-function value is used, it seems to be working OK.
Oops! Something happened and at one point I started getting FF colors instead of system colors. I make some changes and it works again, but I am not so confident, and if someone understands what is going on, please post the correct functions.
For the system colors, you don't get the current value in the Set Function. The value in the Get Function isn't global. I matched the function of the original color checkbox; when the box is checked, I see the document colors. My solution:
value = (goPrefBar.GetPref("browser.display.document_color_use") != 2);
value1 = (goPrefBar.GetPref("browser.display.document_color_use") != 2) ? 2 : 1;
// 1:never use my colors; 2:always use my colors
value2 = (goPrefBar.GetPref("browser.display.use_system_colors") != true) ? true : false;
// true: system colors; false: document colors (I chose to keep the Boolean. I saw about:config change to an integer and the browser seemed to get confused.)
Since I only change the background colors in Firefox and not globally, I've actually commented out the system color lines and instead have:
value = (goPrefBar.GetPref("browser.display.use_document_colors") != false) ? false : true; // true: document colors; false: my colors
and get my desired behavior.
Thanks. Sometimes I panic when something in a code does not work and make things worse. Waiting a while to think it over with a clear mind helps.
Who is online
Users browsing this forum: No registered users and 0 guests