// ==UserScript==
// @name GitHub file list beautifier
// @description Adds colors to files by type, displays small images in place of file-type icons in a repository source tree
// @author wOxxOm
// @namespace wOxxOm.scripts
// @license MIT License
// @include https://github.com/*
// @version 3.0.2
// @icon https://octodex.github.com/images/murakamicat.png
// @run-at document-start
// @grant GM_getValue
// @grant GM_setValue
// @downloadURL none
// ==/UserScript==
/* jshint lastsemic:true, multistr:true, laxbreak:true, -W030, -W041, -W084 */
// Your changes will be remembered in script database even after a forced update of the script
var config = userConfig({
iconSize: 24,
colorSeed1: 13,
colorSeed2: 1299721,
colorSeed3: 179426453,
});
(document.head || document.documentElement).insertAdjacentHTML('beforeend',
''
);
var filetypes = {};
var styledom = document.getElementById('wOxxOm-GHB');
var filesdom = document.getElementsByTagName('table');
var ob = new MutationObserver(GHBsentry);
document.addEventListener('DOMContentLoaded', function() { beautify(filesdom[0]) });
beautify(filesdom[0]);
lazyObserve();
function GHBsentry(mutations) {
if (!/^\/[^\/]+\/[^\/]+(\/tree\/.*)?$/.test(location.pathname)) {
ob.disconnect();
lazyObserve();
return;
}
if (mutations.length == 1 && !mutations[0].addedNodes.length || !filesdom[0])
return;
//console.log([].concat.apply([], mutations.map(m => [].slice.call(m.addedNodes))));
for (var i=0, ml=mutations.length, m; i');
iconCell.classList.add('wOxxOm-image-td');
}
}
}
function addFileTypeStyle(type) {
filetypes[type] = true;
for (var hash=0, i=0, len=type.length; i