Created
December 13, 2008 14:07
-
-
Save satyr/35473 to your computer and use it in GitHub Desktop.
Colorize each tab by the protocol/domain of its content.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Colors each tab by the domain of its content. | |
// original: http://d.hatena.ne.jp/Griever/20081213/1229155926 | |
const DCT_Palette = let(c = '8ace')( | |
['#'+r+g+b for each(r in c) for each(g in c) for each(b in c)]); | |
function pageLoad_domainColorTab(doc){ | |
var [dom] = /^\w+:[\/]*[^\/]+/(doc.location.href) || 0; | |
if(!dom) return; | |
var tbb, idx = -1, nmr = (Cc['@mozilla.org/appshell/window-mediator;1'] | |
.getService(Ci.nsIWindowMediator) | |
.getEnumerator('navigator:browser')); | |
while(idx < 0 && nmr.hasMoreElements()){ | |
tbb = nmr.getNext().getBrowser(); | |
idx = tbb.getBrowserIndexForDocument(doc); | |
} | |
if(idx < 0) return; | |
tbb.mTabs[idx].style.backgroundColor = DCT_Palette[ | |
Array.reduce(dom, | |
function dct_acc(s, c) s + c.charCodeAt(), | |
new Date().getDate()) | |
% DCT_Palette.length]; | |
}//function cmd_ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment