-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmastodon_media_improvements.js
150 lines (136 loc) · 4.61 KB
/
mastodon_media_improvements.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
// ==UserScript==
// @name CortexImplant CSS Improvements
// @namespace http://tampermonkey.net/
// @version 0.8
// @description Improve how media is shown on Mastodon
// @author @Sirs0ri
// @match https://corteximplant.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=corteximplant.com
// @supportURL https://github.com/Sirs0ri/userscripts/issues
// @grant GM_addStyle
// ==/UserScript==
/*
* ==KNOWN ISSUES==
* - This straight up removes overflow: hidden on the emoji's parents,
* I'd be surprised if that *doesn't* break something!
* - Firefox doesn't support :has() yet, unless you manually turn it on via the layout.css.has-selector.enabled flag
*
* ==CHANGES==
* 0.8: Alt-Text improvements: you'll now see an [alt] badge in the top-right corner of media with alt text
* 0.7: The "I've not had enough coffee yet" update
* - part 2 of the 0.6 update, I missed some things.
* 0.6: Disable zoom on account name of a person you're draftign a reply to
* 0.5: A couple more fixes to correctly enable zoom on:
* - Poll Options
* - Profile Info
* - Replies
* - Picture-in-picture player
* - Response-draft
* 0.4: The "I'm testing in production" hotfix
* - Increased emoji's z-index to 2, to pull them on top of embedded images in toots
* 0.3: The "one more thing" update
* - Add a selector I missed for the currently selected DM/Toot
* 0.2: The "all the small things I missed" patch
* - Add support for DMs, Boots, Notifications, Profiles
* - In addition to zooming, make sure hovered icons are in front of other content and fully opaque
* - Since this heavly relies on the relatively new :has() CSS selector, disable the styling when :has() isn't supported
* - Improve documentation
*
* 0.1: initial release
* - Add highlight-on-hover to emojione emotes in toots
*/
(function () {
"use strict"
// Use TamperMonkey's helper to inject CSS
// This heavily relies on :has(), without it the styling has no effect due to the @supports query.
GM_addStyle(`
/* Add "alt" indicator on images, gifs... */
.media-gallery__item:has(img[alt]):after,
.media-gallery__item:has(video[aria-label]):after{
content: "alt";
background: rgba(0 0 0 / 0.6);
color: hsla(0,0%,100%,.7);
position: absolute;
top: 4px;
right: 4px;
z-index: 1;
padding: 0 5px;
border-radius: 4px;
height: 27.1429px;
display: flex;
align-items: center;
}
/* ...and audio, videos */
.audio-player:has(canvas.audio-player__canvas[aria-label]) .video-player__buttons.right:before,
.video-player:has(video[aria-label]) .video-player__buttons.right:before{
content: "alt";
color: hsla(0,0%,100%,.7);
padding: 0 5px;
}
`)
// The :where(...):has(...) statement is used to select a bunch of wrappers that
// would otherwise have overflow: hidden, and remove that while an image is hovered.
GM_addStyle(`
/* Hover-Zoom for emotes */
@supports selector(:has(a, b)) {
/* Temporarily disable overflow on elements restraining the images while hovering */
:where(
/* Toots */
.status__content,
:not(.reply-indicator__display-name)>.display-name,
.status__display-name,
/* Poll Option */
label.poll__option,
/* DMs */
.conversation__content__names,
.detailed-status__display-name,
.detailed-status__display-name strong,
.conversation__content__info,
.conversation__content,
/* Boosts */
.status__prepend>span,
/* follow notifications */
.notification__message>span,
.account__display-name strong,
.account .account__display-name,
/* Profiles */
.account__header__tabs__name h1,
.account__header__content,
/* Profile Info Table */
.account__header__fields dd,
.account__header__fields dt,
/* Replying to a toot - body only */
.reply-indicator,
.reply-indicator__content,
.status__content,
/* Picture in picture player */
.picture-in-picture__header__account,
.picture-in-picture__header .display-name span,
.picture-in-picture__header .display-name strong
):has(img.emojione:hover) {
overflow: revert;
}
/* Add Transition to make it look nice */
:not(
.reply-indicator__header strong,
.emoji-button,
.reactions-bar__item__emoji
)>img.emojione {
transition:
transform 200ms,
opacity 200ms;
}
/* Finally, scale emojis on hover and make sure they're fully visible */
:not(
.reply-indicator__header strong,
.emoji-button,
.reactions-bar__item__emoji
)>img.emojione:hover {
transform: scale(5);
opacity: 1;
z-index: 2;
position: relative;
}
}
`)
})()