您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
Sort directories before files in repository tree view
当前为
// ==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 // ==/UserScript== (()=>{"use strict";const e=document.querySelector(".tree-list");if(!e)return;const t=[],a=[],n=e.querySelectorAll(".name");for(let e=0;e<n.length;e++){const s=n[e];s.classList.contains("tree")?t.push(e):s.classList.contains("blob")&&a.push(e)}const o=e.children.length,i=n.length,s=o/i;if(s*i!==o)return;const r=Array.from(e.children).sort((n,o)=>{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)})()