If you are more than a usual Firefox user, you probably have been using more than one profile1. For quite a while, I use different userChrome.css to distinguish which profile I was using using different tab bar color. Thats very inconvenient because I have to maintain multiple userChrome.css files, each only has small difference in color code.
There is also another issue I wanted to resolve, some stuff I made in Vimperator for one profile, I didnt need those in another profile. But since there is only one ~/.vimperatorrc, its loaded in all profiles.
The key is to use liberator.profileName to identify profiles. I have made few changes to my ~/.vimperatorrc.
A quick code snippet:
:js << EOF switch (liberator.profileName) { case 'Profile A Name': // Do something break; case 'Profile B Name': // Do something else break; } EOF
You probably run some Vimperator commands in that file, such as map, autocmd, etc. You now need to execute those commands in JavaScript, for example:
// Get my damn focus back liberator.execute('autocmd PageLoad (www\\\\.youtube|groups.google)\\\\.com :normal <Esc>');
Basically, you can feed liberator.execute() for whatever command you type in command line of Vimperator. This will get what you used to do, note that those backward slashes in regular expression, you will have to double the amount of those.
I use the following code to change the Vimperator command line bar into red:
// Make command line red for ([k, v] in Iterator(highlight)) { highlight.set(k, highlight.get(k).value.replace('background: #333', 'background: #633')); }
It probably is not the most efficient way to do the job, I just skimmed the source code of Vimperator and came out with that after few tries.
[1] | If you have no idea what Firefox profile is, try to run firefox -ProfileManager. Not sure about the equivalent command on Windows. |
0 comments:
Post a Comment