Skip to content

Instantly share code, notes, and snippets.

@smirea
Last active December 19, 2015 14:39
Show Gist options
  • Save smirea/5970458 to your computer and use it in GitHub Desktop.
Save smirea/5970458 to your computer and use it in GitHub Desktop.
adds a nice title to Mozilla Try pages with an overview of the running revision
// ==UserScript==
// @name Mozilla Try Enhancer
// @namespace http://code4fun.de
// @description adds a nice title to Mozilla Try pages with an overview of the running revision
// @include https://tbpl.mozilla.org/*
// @grant GM_addStyle
// @version 1
// ==/UserScript==
// normal chars: ✗ ↻ ✓ †
let classes = {
'busted': '✗',
'testfailed': '✗',
'running': '↻',
'pending': '↻',
'retry': '↻',
'success': '✓',
'usercancel': '†',
/* 'busted': '💊',
'testfailed': '💊',
'running': '🏃',
'pending': '🏃',
'retry': '🏃',
'success': '🏆',
'usercancel': '🌑',
*/};
setInterval(function update_title () {
let pushes = document.querySelectorAll('#pushes > li.push');
pushes = Array.prototype.slice.call(pushes);
// only take first one
pushes = pushes.slice(0, 1);
let count = {};
for (let push of pushes) {
for (let cls in classes) {
let elems = push.querySelectorAll('.machineResult.'+cls);
let abbrev = classes[cls];
count[abbrev] = (count[abbrev] ? count[abbrev] : 0) + elems.length;
}
}
let str = [];
for (let abbrev in count) {
str.push(abbrev+':'+count[abbrev]);
}
str = str.join(' | ');
document.title = document.title.slice(0, document.title.indexOf('-') + 1) + ' ' + str;
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment