// ==UserScript== // @name Sort directories before files // @description Sort directories before files in repository tree view // @author anhkhoakz // @version 1.0.1 // @match *://git.sr.ht/*/tree(?:/*)? // @namespace anhkhoakz // @icon https://git.sr.ht/static/logo.png // @license GPL-3.0; https://www.gnu.org/licenses/gpl-3.0.html // @downloadURL none // ==/UserScript== (()=>{"use strict";const e=document.querySelector(".tree-list");if(!e)return;const t=[],a=[],n=e.querySelectorAll(".name");for(let e=0;e{const i=Array.prototype.indexOf.call(e.children,n),a=Array.prototype.indexOf.call(e.children,o),c=i/s|0,l=a/s|0,r=t.indexOf(c)!==-1,d=t.indexOf(l)!==-1;return r!==d?r?-1:1:i-a});for(const t of r)e.appendChild(t)})()