Skip to content

Instantly share code, notes, and snippets.

@satyr
Created December 13, 2008 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satyr/35473 to your computer and use it in GitHub Desktop.
Save satyr/35473 to your computer and use it in GitHub Desktop.
Colorize each tab by the protocol/domain of its content.
// 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