-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcortex_implant_styling.user.js
4254 lines (3604 loc) · 113 KB
/
cortex_implant_styling.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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name CortexImplant CSS Improvements
// @namespace http://tampermonkey.net/
// @version 1.7.1
// @description Change the styling for the mastodon instance I'm on
// @author @Sirs0ri
// @updateURL https://raw.githubusercontent.com/Sirs0ri/userscripts/main/cortex_implant_styling.user.js
// @downloadURL https://raw.githubusercontent.com/Sirs0ri/userscripts/main/cortex_implant_styling.user.js
// @supportURL https://github.com/Sirs0ri/userscripts/issues
// @match https://corteximplant.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=corteximplant.com
// @grant GM_addStyle
// @grant GM_getResourceURL
//
// @resource ci_header_mask.avif https://raw.githubusercontent.com/Sirs0ri/userscripts/main/assets/ci_header_mask.avif
// @resource ci_logo_min.svg https://raw.githubusercontent.com/Sirs0ri/userscripts/main/assets/ci_logo_min.svg
// @resource m_boost_sprites.svg https://raw.githubusercontent.com/Sirs0ri/userscripts/main/assets/m_boost_sprites.svg
// ==/UserScript==
/*
* == TODO ==
* - vanilla flavor:
* - post actions have a broken layout
* - header has a border-bottom
* - Profile view is broken
* - 4.3.0 fixes
* - Icons massive (fixed through custom.css)
* - "fav" animation eiert?
*/
/*
* == KNOWN ISSUES ==
* - Firefox doesn't support :has() on <121, unless you manually turn it on via the layout.css.has-selector.enabled flag.
* Starting with 121 (Released 2023-12-19) that flag will be on by default!
* The general restyling shouldn't be affected either way.
* With that flag active, everything should work.
* Affected parts of this stylesheet have a notice at the start.
* - If you're on my git, this incorporates the changes found in mastodon_media_improvements.js
* Use one of the two userscripts. If you're not on my git, ignore this.
* - The glow-on-media might look off on glitch-fork with certain settings. I recommend the following options:
* (under App Settings -> Media)
* - [off] Letterbox Media
* - [off] Full-width media previews
* - [on ] Inline preview cards for external links
* Alternatively, you can turn off the glow effect entirely via the options found in the page footer.
*/
(function () {
"use strict"
// ====================
// Helpers
// ====================
const desktopViewVisible = new Event("desktopViewVisible")
const desktopViewHiddenEvent = new Event("desktopViewHidden")
let _currentInnerWidth = window.innerWidth
const _desktopMinWidth = 1175
const onResize = evt => {
if (_currentInnerWidth < _desktopMinWidth && innerWidth >= _desktopMinWidth) {
dispatchEvent(desktopViewVisible)
} else if (innerWidth < _desktopMinWidth && _currentInnerWidth >= _desktopMinWidth) {
dispatchEvent(desktopViewHiddenEvent)
}
_currentInnerWidth = innerWidth
}
addEventListener("resize", onResize)
/** Register a handler to the "load" event, and when the vew switches from mobile to desktop */
function registerLoadHandlerDesktop (handler) {
addEventListener("load", handler, { once: true })
addEventListener("desktopViewVisible", evt => {
// Run the handler on the next frame, to give the DOM a chance to update
setTimeout(() => handler(evt), 0)
})
}
// Get own account info from embedded "initial-state" JSON
const elem = document.getElementById("initial-state")
const data = JSON.parse(elem.text)
const user = data.accounts[data.meta.me]?.username
const isAdvancedView = document.body.classList.contains("layout-multiple-columns")
// get account color
const avatarLink = data.accounts[data.meta.me]?.avatar_static
function createElem (tagName, options = {}) {
const elem = document.createElement(tagName)
for (const [key, val] of Object.entries(options)) {
switch (key) {
case "class":
elem.classList.add(...val.trim().split(" "))
break
case "innerHTML":
case "innerText":
case "textContent":
case "checked":
case "onclick":
elem[key] = val
break
default:
elem.setAttribute(key, val)
}
}
return elem
}
// #region preferences
// ====================
// Preferences
// ====================
const allOptions = [
{
id: "enableTheme",
textLabel: "general restyling",
textDescription: "Enable my theme across the mastodon webclient.",
defaultvalue: true,
},
{
id: "hideCheckmarks",
textLabel: "hide checkmarks",
textDescription: "Disable the checkmarks Glitch-Fork adds to e.g. the fav- and boost-buttons on Mastodon <4.3.0",
defaultvalue: true,
},
{
id: "disableBouncyAnimations",
textLabel: "disable bouncy animations",
textDescription: "Smooth out some animations that Glitch-Fork would otherwise make super bouncy, e.g. when expanding a post or faving it",
defaultvalue: true,
},
{
id: "highlightReplies",
textLabel: "highlight replies",
textDescription: "Add an indicator to replies in the main timeline, similar to the one for boosts",
defaultvalue: true,
},
{
id: "enableGlowOnMedia",
textLabel: "enable glow on media",
textDescription: "Enable a glow effect around media content embedded in posts",
defaultvalue: true,
},
// {
// id: "showImagesUncropped",
// textLabel: "show images uncropped",
// textDescription: "Enable full-sized images in posts, instead of cropping images to 16/9. If you're experiencing glitches while scrolling through your feed, turn this off!",
// defaultvalue: false,
// },
{
id: "hoverImages",
textLabel: "enlarge images on hover",
textDescription: "Enlarge images in posts to full size on hover, instead of cropping images to 16/9.",
defaultvalue: true,
},
{
id: "highlightMediaWithoutAlt",
textLabel: "highlight media without alt text",
textDescription: "Highlight media without an alt text by adding a visible red bar underneath",
defaultvalue: true,
},
{
id: "popoutComposeBox",
textLabel: "growing compose box",
textDescription: "Make the compose box larger when focussed. This will have no effect in the Advanced View.",
defaultvalue: false,
},
{
id: "freezeTopPosition",
textLabel: "Keep scrollposition in feeds",
textDescription: "When loading new posts on timelines, keep the previously first post in view, instead of staying scrolled all the way to the top. [Simple View only]",
defaultvalue: false,
},
{
id: "imACat",
textLabel: "imACat 🐈",
textDescription: "Meow?",
defaultvalue: false,
},
{
id: "showOldPunks",
textLabel: "[Advanced view] Bring back the old Cyberpunks",
textDescription: "Show the two cyberpunks chilling at the bottom of the compose area. When disabled, John Cyberdon will watch over your toots.",
defaultvalue: false,
},
/* data only, as long as there's no textLabel a setting will not have a GUI */
{
id: "catEarColorsStyle",
default: null,
},
{
id: "catEarColorsLink",
default: null,
},
]
// These preferences will be persisted in localStorage. When upgrading from a version that
// still has preferences defined as booleans make sure to note them down before upgrading!
function loadSettings () {
const loaded = localStorage.getItem(`userscript-sirs0ri-settings-${user}`)
const settings = Object.fromEntries(allOptions.map(o => [o.id, o.defaultvalue]))
if (loaded == null) {
settings._firstRun = true
} else {
const parsed = JSON.parse(loaded)
for (const option of allOptions) {
if (parsed[option.id] != null) settings[option.id] = parsed[option.id]
}
}
return settings
}
function storeSettings (vals) {
const str = JSON.stringify(vals)
localStorage.setItem(`userscript-sirs0ri-settings-${user}`, str)
}
let settingsWhenPopupOpened
function openSettings (evt) {
if (evt) evt.preventDefault()
settingsWhenPopupOpened = { ...settings }
document.body.classList.add("userscript-modal--active")
}
function closeSettings (evt) {
evt.preventDefault()
document.body.classList.remove("userscript-modal--active")
}
const settings = loadSettings()
if (settings._firstRun) {
document.body.classList.add("userscript-modal--firstrun")
delete settings._firstRun
storeSettings(settings)
openSettings()
}
function onSettingChange (evt) {
if (allOptions.map(o => o.id).includes(evt.target.id)) settings[evt.target.id] = evt.target.checked
let needsReload = false
for (const option of allOptions) {
if (settings[option.id] === settingsWhenPopupOpened[option.id]) continue
// else, if the option's changed
needsReload = true
break
}
storeSettings(settings)
if (needsReload) document.querySelector(".userscript-modal-root").classList.add("needs-reload")
else document.querySelector(".userscript-modal-root").classList.remove("needs-reload")
}
const _insertFooter = (evt) => {
const footer = document.querySelector(".link-footer")
if (!footer) {
console.warn("footer not found")
return
}
const insert = createElem("p", { innerHTML: "<strong>Sirs0ri's userscript</strong>: " })
const separator = createElem("span", {
innerHTML: " · ",
ariaHidden: true,
})
const preferencesLink = createElem("a", {
textContent: document.querySelector(".column-link[href='/settings/preferences']").title,
role: "button",
onclick: openSettings,
})
const issuesLink = createElem("a", {
textContent: "Issues",
href: "https://github.com/Sirs0ri/userscripts/issues",
target: "_blank",
})
const codeLink = createElem("a", {
textContent: document.querySelector(".link-footer [href*='github.com']").textContent,
href: "https://github.com/Sirs0ri/userscripts/blob/dev/cortex_implant_styling.js",
target: "_blank",
})
const versionSpan = createElem("span", { innerText: "v" + GM_info.script.version })
insert.appendChild(preferencesLink)
insert.appendChild(separator.cloneNode(true))
insert.appendChild(issuesLink)
insert.appendChild(separator.cloneNode(true))
insert.appendChild(codeLink)
insert.appendChild(separator.cloneNode(true))
insert.appendChild(versionSpan)
footer.insertBefore(insert, footer.firstChild)
}
const _insertSettingsModal = (evt) => {
const modalWrapper = createElem("div", { class: "modal-root userscript-modal-root" })
const modalModal = createElem("div", { class: "userscript-settings__modal" })
const _makeSettingsItem = (id, labelText, description) => {
const wrapper = createElem("div", { class: "userscript-settings__item" })
wrapper.appendChild(createElem("input", {
id,
type: "checkbox",
checked: settings[id],
onclick: onSettingChange,
}))
wrapper.appendChild(createElem("label", { for: id, textContent: labelText }))
wrapper.appendChild(createElem("p", { textContent: description }))
return wrapper
}
const nav = createElem("nav")
nav.appendChild(createElem("a", {
role: "button",
tabindex: "0",
class: "glitch local-settings__navigation__item active",
title: "General",
"aria-label": "General",
innerHTML: `
<i role="img" class="fa fa-cogs fa-fw"></i>
<span>General</span>`,
}))
// const buttonsWrapper = createElem("div", {class: "footer"})
const buttonsWrapper = createElem("footer")
buttonsWrapper.appendChild(createElem("p", {
class: "reload-needed-hint",
innerText: "Some of the settings you changed need the page to be reloaded to apply.",
}))
buttonsWrapper.appendChild(createElem("button", {
tabindex: "0",
title: "Reload",
"aria-label": "Reload",
class: "button reload-needed-hint",
innerHTML: `
<i role="img" class="fa fa-refresh fa-fw"></i>
<span>reload</span>`,
onclick: () => location.reload(),
}))
buttonsWrapper.appendChild(createElem("button", {
tabindex: "0",
title: "Close",
"aria-label": "Close",
class: "button",
innerHTML: `
<i role="img" class="fa fa-times fa-fw"></i>
<span>Close</span>`,
onclick: closeSettings,
}))
nav.appendChild(buttonsWrapper)
modalModal.appendChild(nav)
const settingsWrapper = createElem("div", {
class: "userscript-settings__content",
})
settingsWrapper.appendChild(createElem("p", {
class: "first-run-notice",
innerHTML: `Hi there choom! <br>
This userscript has a settings UI now! You're seeing this because you're running the new version of the script for
the first time. <br>
If you want to access this UI in the future, you'll be able to find it in the page's footer, next to the links to
this instance's about page.`,
}))
settingsWrapper.appendChild(createElem("h1", { innerText: "General" }))
for (const option of allOptions) {
if (option.textLabel) {
settingsWrapper.appendChild(_makeSettingsItem(option.id, option.textLabel, option.textDescription))
}
}
modalModal.appendChild(settingsWrapper)
modalWrapper.appendChild(createElem("div", { class: "modal-root__overlay", role: "presentation", onclick: closeSettings }))
const modalContainer = createElem("div", { class: "modal-root__container", role: "dialog" })
modalWrapper.appendChild(modalContainer)
modalContainer.appendChild(modalModal)
GM_addStyle(`
.link-footer a {
cursor: pointer;
}
.userscript-modal-root {
transition: visibility 200ms;
pointer-events: none;
opacity: 0;
transition: opacity 200ms;
}
.userscript-modal-root > div {
width: 100vw;
}
body.userscript-modal--active {
overflow-y: hidden !important;
margin-right: 12px;
}
body.userscript-modal--active .userscript-modal-root {
pointer-events: revert;
opacity: 1;
}
body.userscript-modal--active .userscript-settings__modal {
pointer-events: auto;
}
.userscript-settings__modal {
background: #d9e1e8;
border-radius: 8px;
color: #282c37;
height: 80vh;
max-height: 450px;
max-width: 740px;
overflow: hidden;
position: relative;
width: 80vw;
display: flex;
box-sizing: border-box;
}
.userscript-settings__modal nav {
display: flex;
flex-direction: column;
background: #f2f5f7;
font-size: 15px;
line-height: 20px;
overflow-y: auto;
width: 212px;
flex: 1 0 auto;
}
.userscript-settings__modal nav footer {
margin-top: auto;
padding: 15px;
display: grid;
font-size: 13px;
}
.userscript-settings__modal nav footer > *+* {
margin-top: 15px
}
.userscript-settings__content {
padding: 15px;
overflow-y: scroll;
}
.userscript-settings__content .first-run-notice {
margin-bottom: 20px;
display: none;
}
body.userscript-modal--firstrun .userscript-settings__content .first-run-notice {
display: block;
}
.userscript-settings__modal h1 {
font-size: 18px;
font-weight: 500;
line-height: 24px;
margin-bottom: 20px;
}
.userscript-settings__item {
padding-inline-start: 4ch;
position: relative;
}
.userscript-settings__item + .userscript-settings__item {
margin-top: 15px;
}
.userscript-settings__item input[type="checkbox"] {
position: absolute;
top: 0;
left: 0;
}
.userscript-settings__item p {
opacity: 0.8;
}
.reload-needed-hint {
visibility: hidden;
}
.needs-reload .reload-needed-hint {
visibility: visible;
}
`)
document.body.appendChild(modalWrapper)
}
const insertSettings = (evt) => {
_insertFooter(evt)
// only insert the modal during the "load" event, not on subsequent runs of this functions when the view switches from mobile to desktop
if (evt.type !== "load") return
_insertSettingsModal(evt)
}
if (isAdvancedView) {
registerLoadHandlerDesktop((evt) => setTimeout(() => insertSettings(evt), 200))
} else {
registerLoadHandlerDesktop(insertSettings)
}
// #endregion
// Use TamperMonkey's helper to inject CSS
// see https://codepen.io/mattgrosswork/pen/VwprebG
/* general setup */
GM_addStyle(`
p {
line-height: 1.5;
}
body {
/* border radii */
--border-radius-button: 10px;
--border-radius-button-between: 3px;
/* COLORS */
--hsl-white: 0deg 0% 100%;
--color-white: hsl(var(--hsl-white));
--neon-glow-hsl: 219deg 100% 50%;
/* hl is a color to be used as highlight ontop of another color */
--color-primary: hsl(239.65deg 100% 66.47%);
--color-hl-primary: hsl(240deg 100% 83%);
/* used in the neon bars in the menu */
--hsl-offwhite-blue: 224deg 60% 81%;
--color-offwhite-primary: hsl(224deg 60% 81%);
--color-green: #388e3c; /* Unlisted posts */
--color-blue: #1976d2; /* formerly public posts */
--color-red: #d32f2f; /* Direct posts */
--color-yellow: hsl(48 71% 54%); /* Private posts - original: ffa000*/
/* favs */
--hsl-gold: 41 100% 45%;
--color-gold: hsl(var(--hsl-gold));
/* boosts */
--hsl-purple: 240 100% 77%;
--color-purple: hsl(var(--hsl-purple));
/* reports */
--hsl-orange: 22 100% 45%;
--color-orange: hsl(var(--hsl-orange));
/* page background */
--color-grey-0: hsl(224deg 17% 9%);
/* .account-timeline__header -> background
* explore -> subheader -> background
*/
--color-grey-1: hsl(223deg 17% 14%);
/* .search__input -> background
* .column-back-button--slim [role="button"]:after -> border
* #tabs-bar__portal>button:after -> border
* .column-header__wrapper:after -> border
* posts -> background
* search results -> background
* explore links -> background
* ::-webkit-scrollbar-thumb -> background
* ::-webkit-scrollbar-track:active -> background
* ::-webkit-scrollbar-track:hover -> background
*/
--color-grey-2: hsl(224deg 17% 19%);
/* .column-back-button--slim [role="button"] -> background 0.8
* #tabs-bar__portal>button -> background 0.8
* .column-header__wrapper -> background 0.8
* selected post -> background
* .about:before -> background
* scrollbars -> ???
* body.layout-multiple-columns .column-header -> background
*/
--hsl-grey-3: 227deg 17% 23%;
--color-grey-3: hsl(var(--hsl-grey-3));
/* .dismissable-banner -> border
* posts -> border
* search results -> border
* explore links -> border
* .explore__search-results>button -> border
* .account__section-headline -> border
* .notification__filter-bar -> border
* .account-timeline__header -> outline
* lists .column-inline-form -> outline
* ::-webkit-scrollbar-thumb -> border
* ::-webkit-scrollbar-thumb:hover -> background
*/
--color-grey-4: hsl(227deg 17% 27%);
/* .search__input -> background
* .column-header__collapsible -> background
* .account__action-bar__tab.active -> border
* .account__header__bio .account__header__fields -> border
* body.layout-multiple-columns .drawer__inner -> background
* body.layout-multiple-columns .drawer__inner .navigation-bar -> background
*/
--color-grey-5: hsl(227deg 17% 31%);
/* .column-header__button:hover:before -> background
* .column-header__back-button:hover:before -> background
* .account__section-headline :is(button, a):hover span:before -> background
* .notification__filter-bar button:hover span:before -> background
* .notification__filter-bar button:hover i:after -> background
* .account-card -> border
* ::-webkit-scrollbar-thumb:hover -> border
* ::-webkit-scrollbar-thumb:active -> background
* body.layout-multiple-columns .drawer--header -> border
* .search__input -> border
*/
--color-grey-6: hsl(227deg 17% 41%);
/* .compose-form__autosuggest-wrapper -> border
* .compose-form__buttons-wrapper -> border
* .compose-form .spoiler-input -> border
* .column-back-button--slim [role="button"]:hover:after -> border
* #tabs-bar__portal>button:hover:after -> border
* .column-header__wrapper:hover:after -> border
* selected post -> border
* .about:before -> border
* ::-webkit-scrollbar-thumb:active -> border
*/
--color-grey-7: hsl(227deg 17% 51%);
/* Notifications -> border
*/
--hsl-grey-8: 227deg 17% 71%;
--color-grey-8: hsl(var(--hsl-grey-8));
/* .compose-form__buttons-wrapper -> background
*/
--color-grey-9: hsl(227deg 17% 81%);
--anim-dur: 200ms;
--neon-box-shadow:
/* White glow */
0 0 7px hsla(var(--hsl-white) / 1),
0 0 10px hsla(var(--hsl-white) / 1),
0 0 21px hsla(var(--hsl-white) / 1),
/* Colored glow */
0 0 42px hsla(var(--neon-glow-hsl) / 1),
0 0 82px hsla(var(--neon-glow-hsl) / 1),
0 0 92px hsla(var(--neon-glow-hsl) / 1),
0 0 102px hsla(var(--neon-glow-hsl) / 1),
0 0 151px hsla(var(--neon-glow-hsl) / 1);
--neon-box-shadow-small:
/* White glow */
0 0 6px -2px hsla(var(--hsl-white) / 0.4),
0 0 10px hsla(var(--hsl-white) / 0.2),
0 0 15px hsla(var(--hsl-white) / 0.1),
/* Colored glow */
0 0 10px hsla(var(--neon-glow-hsl) / 0.07),
0 0 25px hsla(var(--neon-glow-hsl) / 0.05),
0 0 47px hsla(var(--neon-glow-hsl) / 0.12),
/* White inside glow */
inset 0 0 5px hsla(var(--hsl-white) / 0.3);
}
@keyframes flicker-in {
0% { opacity: 0 }
40% { opacity: 0.7 }
75% { opacity: 0.4 }
100% { opacity: 1 }
}
`)
settings.hideCheckmarks && GM_addStyle(`
/* disable checkmark on buttons */
.detailed-status__button .icon-button.active:after,
.status__action-bar-button.active:after {
content: "";
display: none
}
`)
settings.highlightReplies && GM_addStyle(`
@media screen and (min-width: 1175px) {
.status.status__wrapper-reply:not(.status--in-thread):not(.muted) {
--status-extra-top-padding: calc(1.5em + 10px);
}
.status.status__wrapper-reply:not(.status--in-thread):not(.muted) .status__info:not(aside + .status__info) {
padding-top: var(--status-extra-top-padding, 0px);
position: relative;
}
.status.status__wrapper-reply:not(.status--in-thread):not(.muted) .status__info:not(aside + .status__info):before {
color: #606984;
font-size: 14px;
position: absolute;
top: 0px;
}
.status.status__wrapper-reply:not(.status--in-thread):not(.muted) .status__info:not(aside + .status__info):before {
content: "\\21B6 Replying to a conversation";
border: 1px solid;
border-radius: 100vmax;
padding: 1px 8px;
}
.status.status__wrapper-reply:not(.status--in-thread):not(.muted) aside.status__prepend > span:after {
content: " a reply"
}
}
`)
settings.disableBouncyAnimations && GM_addStyle(`
/* ====================
* de-springyfy anims
* ==================== */
.no-reduce-motion .status__collapse-button>.fa-angle-double-up,
.no-reduce-motion .status__collapse-button>.icon {
transition: transform 200ms ease-in-out, color 200ms;
animation: none !important;
}
@keyframes rotateIn {
from { transform: rotate(0turn); }
to { transform: rotate(2.4turn); }
}
@keyframes rotateOut {
from { transform: rotate(2.4turn); }
to { transform: rotate(0turn); }
}
.no-reduce-motion .icon-button.star-icon.deactivate>.fa-star,
.no-reduce-motion .icon-button.star-icon.deactivate>.icon {
animation: rotateOut 750ms;
}
.no-reduce-motion .icon-button.star-icon.activate>.fa-star,
.no-reduce-motion .icon-button.star-icon.activate>.icon {
animation: rotateIn 750ms;
}
`)
settings.showImagesUncropped && GM_addStyle(`
/* Force all images to be in their original aspect ratio, not 16/9 */
.media-gallery, video {
aspect-ratio: unset !important;
}
.spoiler-button:not(.spoiler-button--minified) + .media-gallery__item {
aspect-ratio: 16 / 9;
}
`)
settings.freezeTopPosition && GM_addStyle(`
body.layout-single-column.at-top .column[aria-label] {
margin-top: 1px;
}
.tabs-bar__wrapper {
transition: box-shadow 300ms;
}
body.layout-single-column.pinned .tabs-bar__wrapper {
box-shadow: 0px 5px 25px -20px var(--color-blue);
}
/* add a "pause" icon to the column header */
.column-header > button::after {
content: "";
font: normal normal normal 14px/1 FontAwesome;
opacity: 0;
transition: opacity 300ms;
margin-inline-start: 5px;
color: var(--color-grey-7);
display: inline-block;
scale: 0.9;
align-self: center;
}
body.layout-single-column.pinned .column-header > button::after {
opacity: 1;
}
`)
if (settings.freezeTopPosition) {
let atTop = true
let debounce = null
const scrollHandler = evt => {
const previousAtTop = atTop
let pinned = false
if (window.scrollY === 0) {
// when the user's scrolled to the very top, scroll down 1px to keep the currently first post "pinned" at its current position
// Otherwise, Mastodon will keep the newest post at the top and you'll use your scrolling position.
atTop = true
} else if (window.scrollY === 1) {
// When the window's scrolled to 1px, add some UI later to display that the feed is "pinned"
pinned = true
} else {
atTop = false
}
if (pinned) {
document.body.classList.add("pinned")
} else {
document.body.classList.remove("pinned")
}
if (atTop !== previousAtTop) {
if (debounce) clearTimeout(debounce)
debounce = setTimeout(topChangeHandler, atTop ? 500 : 0)
}
}
const topChangeHandler = () => {
if (atTop) {
const el = document.querySelector("body.layout-single-column .column[aria-label]")
if (el == null) return
document.body.classList.add("at-top")
window.scrollBy(0, 1)
} else {
document.body.classList.remove("at-top")
}
}
settings.freezeTopPosition && window.addEventListener("scroll", scrollHandler)
settings.freezeTopPosition && topChangeHandler()
}
// TODO:
// - [x] Images overlap Emotes
// - [ ] Make sure images are always fully visible, like a position sticky?
/* Firefox animates the max-height from the image's original height to 100cqh for some reason, every time the image is added to the DOM
* This worakround only applies the transition on hover, meaning the images won't animate on load. */
const mouseoverHandler = e => {
if (!["IMG", "CANVAS", "VIDEO"].includes(e.target.nodeName)) return
let target
if (e.target.parentElement.classList.contains("media-gallery__item-thumbnail") ||
e.target.classList.contains("media-gallery__item-gifv-thumbnail")) {
target = e.target
} else if (e.target.nextElementSibling?.classList.contains("media-gallery__item-thumbnail")) {
target = e.target.nextElementSibling.querySelector("img")
}
if (!target) return
target.style.transition = "background 200ms, max-height 200ms, min-height 200ms"
// Remove the data-hovered attribute from any previously hovered article
document.querySelectorAll("article[data-hovered]").forEach(el => {
delete el.dataset.hovered
})
// Apply the data-hovered attribute to the parent article of this media item's post
const article = e.target.closest("article[data-id]")
if (article) {
article.dataset.hovered = true
}
}
settings.hoverImages && document.addEventListener("mouseover", mouseoverHandler)
settings.hoverImages && GM_addStyle(`
.media-gallery {
/* overlap emotes */
z-index: 101;
overflow: visible;
container: parent / size;
}
.media-gallery:hover {
z-index: 102;
}
.media-gallery :where(.spoiler-button, .media-gallery__item__badges) {
transition: opacity 200ms, transform 200ms;
}
.media-gallery:hover .spoiler-button.spoiler-button--minified:not(:hover),
.media-gallery:hover .spoiler-button.spoiler-button--minified:not(:hover) ~ div .media-gallery__item__badges:not(:hover) {
opacity: 0.5;
transform: scale(0.9)
}
.media-gallery .media-gallery__item__badges {
z-index: 2;
}
.media-gallery .media-gallery__item {
align-items: center;
display: flex !important;
overflow: visible;
}
.media-gallery .media-gallery__item:hover {
z-index: 3;
}
.media-gallery .media-gallery__item:not(.media-gallery__item--tall) {
--height: calc(50cqh - (var(--border-radius-button-between) + var(--extra-gap, 0px)) / 2);
height: var(--height);
}
.media-gallery :is(#fake, .media-gallery__item-thumbnail, .media-gallery__gifv) {
overflow: visible !important;
position: relative;
height: auto;
transition: transform 200ms ease-out, border-radius 200ms;
}
.media-gallery .media-gallery__item:hover :is(.media-gallery__item-thumbnail, .media-gallery__gifv) {
transform: scale(1.15);
border-radius: var(--border-radius-button);
}
.layout-multiple-columns .media-gallery .media-gallery__item:hover :is(.media-gallery__item-thumbnail, .media-gallery__gifv) {
transform: scale(1.05)
}
.media-gallery .media-gallery__item-thumbnail img,
.media-gallery .media-gallery__gifv video {
height: auto;
display: block;
max-height: 100cqh;
min-height: 50cqh;
}
.media-gallery .media-gallery__item--tall :is(img, video) {
min-height: 65cqh;
}
.media-gallery .media-gallery__item:not(.media-gallery__item--tall) .media-gallery__item-thumbnail img,
.media-gallery .media-gallery__item:not(.media-gallery__item--tall) .media-gallery__gifv video {
max-height: var(--height);
}
.media-gallery .media-gallery__item:hover :where(img, video) {
max-height: 60vh !important;
min-height: 0cqh;
max-width: 80vw;
}
article {
z-index: 1;
position: relative;
}
article:has(.media-gallery__item:hover),
article[data-hovered] {
z-index: 2;
}
`)
settings.enableGlowOnMedia && GM_addStyle(`
/* ====================
* Glow on Media
* ==================== */
/* Important note for glitch-fork users:
it's HIGHLY recommended to disable the following
options in the "app settings" (left sidebar):
- full-width media previews
*/
.media-gallery {