-
Notifications
You must be signed in to change notification settings - Fork 5
/
old.reddit.compact.user.js
378 lines (368 loc) · 11 KB
/
old.reddit.compact.user.js
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
// ==UserScript==
// @name Compact Lemmy to old.Reddit Re-format (Lemmy v0.18)
// @namespace https://github.com/soundjester/lemmy_monkey
// @description Reformat widescreen desktop to look more like Reddit
// @version 2.6
// @author mershed_perderders, DarkwingDuck, dx1@lemmy.world, Djones4822, Jakylla
// @updateURL https://github.com/soundjester/lemmy_monkey/raw/main/old.reddit.compact.user.js
// @downloadURL https://github.com/soundjester/lemmy_monkey/raw/main/old.reddit.compact.user.js
// @match https://*/*
// @run-at document-idle
// ==/UserScript==
(function() {
'use strict';
/***********************************/
/* set desired thumbnail size here */
/* 70px - compact default */
/* 100px - large thumbnail default */
/***********************************/
var thumbnailSize = 70;
var readingWidth = 940; /*controls the width of comments and text posts on individual post pages - default=940*/
/***********************************/
//Thank you God!
var isLemmy;
try {
isLemmy = document.head.querySelector("[name~=Description][content]").content === "Lemmy";
} catch (_er) {
isLemmy = false;
}
/*modify the presentation of fonts based on thumbnail size - larger thumbnails make resized test look a little silly...*/
if(thumbnailSize<100){
var postTitleFont = "font-size: 1rem !important;";
var voteBarFont = "font-size: 0.95em !important;";
var voteBarTopMargin = "unset";
var smallTextFont = "80%";
var postPFPSize = "1.25rem";
var postFedLinks = "font-size: 0.75rem !important;";
} else {
var postTitleFont = "";
var voteBarFont = "";
var voteBarTopMargin = "unset"
var smallTextFont = "unset !important;";
var postPFPSize = "";
var postFedLinks = "";
}
function AppendCommentCountText(container) {
var svgElem = container.querySelectorAll("svg")[0].outerHTML;
var numComms = container.title;
var spanElem = container.querySelectorAll("span");
var spanElemHTML = "";
if(spanElem[0]){
spanElemHTML = " " + spanElem[0].outerHTML
}
container.innerHTML = svgElem + numComms + spanElemHTML;
return;
}
async function ApplyCommentCountText(element) {
const observer = new MutationObserver(function(mutationsList) {
for (let mutation of mutationsList) {
if (mutation.type === 'childList') {
for (let addedNode of mutation.addedNodes) {
try {
var comm_count = addedNode.querySelectorAll(".btn.btn-link.btn-sm.text-muted.ps-0");
comm_count.forEach(AppendCommentCountText);
} catch (_er) {
return;
}
}
}
}
});
observer.observe(element, { childList: true, subtree: true });
}
function AppendPostURL(container) {
var tld_link = container.querySelectorAll(".d-flex.text-muted.align-items-center.gap-1.small.m-0")[0];
var post_details = container.querySelectorAll("span.small")[0];
if (tld_link) {
var post_detail = tld_link.nextSibling.innerText;
post_details.innerHTML += " • " + tld_link.innerHTML
}
return;
}
async function ApplyAppendPostURL(element) {
const observer = new MutationObserver(function(mutationsList) {
for (let mutation of mutationsList) {
if (mutation.type === 'childList') {
for (let addedNode of mutation.addedNodes) {
try {
var comm_count = addedNode.querySelectorAll("article > .col-12.col-sm-9 > .row > .col-12");
comm_count.forEach(AppendPostURL);
} catch (_er) {
return;
}
}
}
}
});
observer.observe(element, { childList: true, subtree: true });
}
// Lemmy to old.Reddit style reformats (portable custom stylesheet)
if (isLemmy) {
const css = `
/**************************/
/* NSFW automatic un-blur */
/**************************/
.img-blur {
filter: none !important;
-webkit-filter: none !important;
-moz-filter: none !important;
-o-filter: none !important;
-ms-filter: none !important;
}
/***************/
/* main page */
/***************/
:root{
--bs-body-font-size: 0.9375rem;
}
.home, .post, .container-xxl, .container-xl, .container-lg, .container-md, .container-sm, .container {
max-width: 100% !important;
}
#navbar {
min-width: 100%;
}
/* padding between navbar and main content */
.mt-4, .my-4 {
margin-top: 0.5rem !important;
}
.vote-bar {
min-width: 2.5em;
}
/*sidebar width*/
.col-md-4 {
flex: 0 0 20% !important;
width: 20% !important;
}
/*main post area (witdh optimized for widescreen)*/
.col-md-8 {
flex: 0 0 80% !important;
width: 80%;
max-width: unset;
}
/* Fix user drop down menu position */
.dropdown-content {
right: 0px;
}
.dropdown-menu.show {
width: 100%;
}
hr {
display: none;
}
/*table styles - primarily used on the "Communities" page*/
.table-responsive {
margin-top: 0.5em;
}
.table-sm td, .table-sm th {
padding: 0.1rem;
vertical-align: middle;
}
/* user profile and community icons on posts */
.small > a > picture > img {
width: `+postPFPSize+`;
height: `+postPFPSize+`;
}
/************************/
/* Lemmy v0.17.4 hacks */
/************************/
.col-sm-2 {
flex: 0 0 1%;
max-width: 16.66667%;
}
ul.text-muted.small > li.list-inline-item > a > picture > img,
ul.text-muted.small > li.list-inline-item > span > a > picture > img{
height: 1.5em !important;
width: 1.5em !important;
}
/***************************/
/* main page post listing */
/***************************/
/* post title font size*/
.h5, h5 {
`+postTitleFont+`
margin-bottom: 0.1rem !important;
}
/* enforce consistent spacing between posts in the post list*/
.post-listing {
margin-top: 0px !important;
min-height: `+(thumbnailSize+10)+`px;
}
/*hide link TLD until it is moved back to the old spot*/
.small.m-0 {
display: none !important;
}
/*comment number and fediverse/lemmy links*/
.ps-0 {
`+postFedLinks+`
}
/* highlight number of new comments */
a > span.fst-italic {
color: var(--bs-orange) !important;
}
/*media collapse/expand button - appears after post title for offsite links that have a thumbnail*/
.btn.btn-sm.text-monospace.text-muted.d-inline-block {
padding-top: 0;
padding-bottom: 0;
}
.text-body.mt-2.d-block{
display: none !important;
}
/***************/
/* voting area */
/***************/
/*can be modified as you like*/
.vote-bar {
`+voteBarFont+`
flex: 0 0 4% !important;
max-width: 4% !important;
margin-top: `+voteBarTopMargin+` !important;
}
.col.flex-grow-0 {
align-self: center !important;
}
.small, small {
font-size: `+smallTextFont+`;
font-weight: 400;
}
/******************/
/* thumbnail area */
/******************/
/*keep thumbnails as square as we can and about the size of each post row*/
.post-media {
min-width: `+thumbnailSize+`px !important;
max-width: `+thumbnailSize+`px !important;
margin-right: 1em !important;
}
.thumbnail {
min-height: `+thumbnailSize+`px !important;
max-height: `+thumbnailSize+`px !important;
min-width: `+thumbnailSize+`px !important;
max-width: `+thumbnailSize+`px !important;
background-color: #333;
object-fit: scale-down; /* instead of "cover" */
}
/*this is needed for videos/gifs*/
.embed-responsive {
min-height: `+thumbnailSize+`px !important;
max-height: `+thumbnailSize+`px !important;
min-width: `+thumbnailSize+`px !important;
max-width: `+thumbnailSize+`px !important;
}
/*apply specific styling to text posts*/
a[href^="/post/"] .thumbnail {
border: 1px solid #333;
background-color: unset !important;
}
.px-0 {
max-height: `+thumbnailSize+`px !important;
}
/************/
/* comments */
/************/
/* Profile and Community Banner size */
.position-relative.mb-2 {
max-width: 730px;
}
/* restrict post and comment width - adjust to preference */
/* may use li[role="comment"] instead of .md-div - this fully restricts all comment elements (eg. divider lines_ */
#postContent, .md-div, .alert-warning {
max-width: `+readingWidth+`px;
}
.mb-3.row {
max-width: `+(readingWidth+25)+`px; /*top-comment textarea needs extra width*/
}
/*top comment doesn't need to hug the comment sort buttons.*/
.comments:first-child {
margin-top: 0.5rem !important;
}
/*allow top-level comment box to be resized*/
div > textarea {
resize: both !important;
}
/*increase the indent for child comments*/
.ms-1 {
margin-left: 1em !important;
}
/**********************************************/
/** Specific screen size (mobile) adjustments */
/**********************************************/
@media screen and (min-width: 1981px) {
#app {
max-width: 1980px;
margin-left: auto;
margin-right: auto;
}
}
@media screen and (min-width: 1200px) and (max-width: 1640px) {
.col-md-4 {
flex: 0 0 25% !important;
max-width: 25%;
}
.col-md-8 {
flex: 0 0 75% !important;
max-width: 75%;
}
}
@media screen and (max-width: 1199px) and (min-width: 992px) {
.col-12 {
flex: 1 0 75% !important;
}
.col-md-4 {
flex: 0 0 25% !important;
max-width: 25%;
}
.vote-bar {
flex: 0 0 8% !important;
max-width: 8% !important;
}
.col-sm-9 {
max-width: unset !important;
}
}
@media screen and (max-width: 768px) and (min-width: 576px) {
.col-12 {
flex: 0 0 100% !important;
max-width: 100%;
}
.col-sm-9 {
flex: 0 0 72% !important;
max-width: 72%;
}
.vote-bar {
flex: 0 0 8% !important;
max-width: 8% !important;
}
}
@media screen and (max-width: 575px) {
#tagline {
padding-right: 1em;
}
.col-12 {
flex: 0 0 100% !important;
}
.col-8 {
flex: 0 0 75% !important;
max-width: 75%;
}
.col-4 {
flex: 0 0 25% !important;
max-width: 25%;
justify-content: flex-end !important;
display: flex !important;
}
}`
const styleTag = document.createElement('style');
styleTag.appendChild(document.createTextNode(css));
document.head.appendChild(styleTag);
/*append comment icon with "comment" text*/
var comm_count = document.querySelectorAll(".btn.btn-link.btn-sm.text-muted.ps-0");
comm_count.forEach(AppendCommentCountText);
/*Apply AppendCommentCountText to dynamically loaded elements */
ApplyCommentCountText(document.documentElement);
/*append post TLD link to post detail area*/
var post_info = document.querySelectorAll("article > .col-12.col-sm-9 > .row > .col-12");
post_info.forEach(AppendPostURL);
/* Apply AppendPostURL to dynamically loaded elements */
ApplyAppendPostURL(document.documentElement);
}
})();