Skip to content

Instantly share code, notes, and snippets.

@satyr
Created February 5, 2016 11:06
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/7cb5de379e2534333c52 to your computer and use it in GitHub Desktop.
Save satyr/7cb5de379e2534333c52 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name domain color tab
// @desc Color-codes each tab by the domain of its content.
// @include main
// @compat Fx39+
// @author satyr
// @license X
// ==/UserScript==
{
let c = '8ace'
, palette = [for (r of c) for (g of c) for (b of c) '#'+r+g+b]
, {require} =
Cu.import('resource://devtools/shared/Loader.jsm', null).devtools
require('sdk/tabs').on('ready', tab => {
var [, domain] = /^https?:\/+([^\/]+)/.exec(tab.url) || []
if (!domain) return
require('sdk/view/core').viewFor(tab).style.backgroundColor = palette[
Array.reduce(
domain, (s, c) => s + c.charCodeAt(), new Date().getDate()
) % palette.length
]
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment