summaryrefslogtreecommitdiff
path: root/theme_userscript.js
blob: dd9ee01095accab0c5c8a1f01a520ed80d823c28 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// ==UserScript==
// @name         DEV git.syndamia.com stylesheet
// @namespace    http://tampermonkey.net/
// @version      2026-03-17
// @description  try to take over the world!
// @author       You
// @match        https://git.syndamia.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=qwant.com
// @grant        none
// ==/UserScript==

var style = document.createElement('style')

style.textContent = `
body, div#cgit {
  margin: 0;
  padding: 0;
}
div.content {
  min-height: calc(100vh - 17em);
  border-bottom: none !important;
  padding-bottom: 4em !important;
}
div#cgit {
  font-size: 11pt;
  position: relative;
  min-height: 100vh;
}
div.footer {
  position: absolute;
  bottom: 0;
  width: 100vw;
  border-top: solid 3px #ccc;
}
div#cgit, a {
  color: #fafafa !important;
}
a[href$=".zip"], a[href$=".tar"], a[href$=".tar.gz"] {
  color: #f5e16c !important;
}
body, div#cgit, tr {
  background-color: #212025 !important;
}
table.list {
    border-collapse: separate !important;
    border-spacing: 0 !important;
}
table.list th {
  background-color: #484848;
  border: 1px solid #404040;

  padding: 0.5rem !important;
  font-size: 1.1em;
  margin: 1em 0;
}
table.list th:not(:first-child):not(last-child) {
  border-left: none;
  border-right: none;
}
table.list th:first-child {
  border-right: none;
  border-top-left-radius: 6px;
}
table.list th:last-child {
  border-left: none;
  border-top-right-radius: 6px;
}
table.list td {
  background-color: #303030;
  border-bottom: 1px solid #404040 !important;
  padding: 0.25em 0.5em !important;
}
table.list td:first-child {
  border-left: 1px solid #404040 !important;
}
table.list td:last-child {
  border-right: 1px solid #404040 !important;
}
table.list tr.nohover > td[colspan="5"] {
  background-color: initial;
  border: none !important;
}
table.list td.reposection {
  color: #63a6e9 !important;
}
table#header tr:first-child td {
  padding-top: 0.5em;
}
table#header tr:last-child td {
  padding-bottom: 2em;
}
table#header td, table.tabs td, div.footer {
  background-color: #303030;
}
div.footer {
  margin-top: 0 !important;
  padding: 0.5em 0;
}
table#header, table.tabs {
  margin: 0 !important;
}
table#header td.main, table#header td.main a {
  color: #f57f6c !important;
}
table#header td.main a[href="/"] {
  color: #fafafa !important;
}
div.path {
  color: #fefefe !important;
  background-color: #453894 !important;
  padding-bottom: 5px !important;
}
table.tabs {
  border-color: #5b5bbd !important;
}
table.tabs td a.active {
  background-color: #5b5bbd !important;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}

select, input {
  color: #fafafa;
  background-color: #428fdc;
  box-shadow: inset 0 0 0 1px #63a6e9;
  border: none;
  border-radius: 3px;
}

table.commit-info td, table.commit-info th,
div.commit-subject, div.commit-msg,
div.cgit-panel, div.cgit-panel table td,
div.diffstat-header, table.diffstat > tbody > tr > td, div.diffstat-summary, table.diff td {
  background-color: #303030 !important;
}
table.commit-info tr:first-child td, table.commit-info tr:first-child th {
  padding-top: 2em !important;
}
table.commit-info tr:last-child td, table.commit-info tr:last-child th {
  padding-bottom: 2em !important;
}
table.commit-info td:first-child, table.commit-info th:first-child {
  padding-left: 1em !important;
}
table.commit-info td:last-child, table.commit-info th:last-child {
  padding-right: 1em !important;
}
table.commit-info tr:first-child td:first-child, table.commit-info tr:first-child th:first-child {
  border-top-left-radius: 6px;
}
table.commit-info tr:first-child td:last-child, table.commit-info tr:first-child th:last-child {
  border-top-right-radius: 6px;
}

div.commit-subject {
  padding: 1.5em 1em 0 1em !important;
  border-top-right-radius: 6px;
}
div.commit-msg {
  padding: 1.5em 1em 1em 1.25em !important;
  margin-top: -1em !important;
}
div.diffstat-header, table.diffstat > tbody > tr > td, div.diffstat-summary, table.diff td {
  padding: 0 1.25em !important;
}
table.diff tr:last-child td {
  padding-bottom: 1em !important;
}
`

document.head.appendChild(style)

const list = document.getElementsByClassName('list')[0]
const table = list.children[0]
const rows = table.children

if (list.summary === "tree listing") {
    /* Reorder directories before files */
    var lastDir = 1
    for (let i = 1; i < rows.length; ++i) {
        if (rows[i].children[0].innerText.startsWith('d')) {
            if (i > lastDir) {
                table.insertBefore(rows[i], rows[lastDir])
            }
            ++lastDir
        }
    }
    /* Human size format */
    for (const row of rows) {
        if (row.children[2].classList.contains('ls-size')) {
            let size = row.children[2].innerText
            if (size < 1024) {
                size += ' B'
            }
            else if (size < 1048576) {
                size = (size / 1024).toFixed(1) + ' KiB'
            }
            else if (size < 1073741824) {
                size = (size / 1048576).toFixed(1) + ' MiB'
            }
            else {
                size = (size / 1073741824).toFixed(1) + ' GiB'
            }
            row.children[2].innerText = size
        }
    }
}