Created
February 5, 2016 11:06
-
-
Save satyr/7cb5de379e2534333c52 to your computer and use it in GitHub Desktop.
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
// ==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