Skip to content

Instantly share code, notes, and snippets.

@satyr satyr/dct.uc.js
Created Feb 5, 2016

Embed
What would you like to do?
// ==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
You can’t perform that action at this time.