-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmh-no-sidebar.user.js
More file actions
201 lines (167 loc) · 6.01 KB
/
Copy pathmh-no-sidebar.user.js
File metadata and controls
201 lines (167 loc) · 6.01 KB
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
// ==UserScript==
// @name 🐭️ MouseHunt - No Sidebar
// @version 1.3.0
// @description Hides the sidebar and moves it into a tab in the top menu.
// @license MIT
// @author bradp
// @namespace bradp
// @match https://www.mousehuntgame.com/*
// @icon https://i.mouse.rip/mouse.png
// @grant none
// @run-at document-end
// @require https://cdn.jsdelivr.net/npm/mousehunt-utils@1.7.3/mousehunt-utils.js
// @require https://cdn.jsdelivr.net/npm/script-migration@1.1.1
// ==/UserScript==
((function () {
'use strict';
const moveSidebar = () => {
// Create menu tab.
const menuTab = document.createElement('div');
menuTab.classList.add('menuItem');
menuTab.classList.add('dropdown');
menuTab.classList.add('sidebar');
// Register click event listener.
menuTab.addEventListener('click', () => {
menuTab.classList.toggle('expanded');
});
// Make title span.
const menuTabTitle = document.createElement('span');
menuTabTitle.innerText = 'Sidebar';
// Make arrow div.
const menuTabArrow = document.createElement('div');
menuTabArrow.classList.add('arrow');
// Create menu tab dropdown.
const dropdownContent = document.createElement('div');
dropdownContent.classList.add('dropdownContent');
// Grab sidebar content.
const sidebarUser = document.querySelector('.pageSidebarView-user');
if (sidebarUser) {
dropdownContent.appendChild(sidebarUser);
}
const scoreBoardRankings = document.querySelectorAll('.scoreboardRelativeRankingTableView-table');
if (scoreBoardRankings) {
const scoreBoardRankingWrapper = document.createElement('div');
scoreBoardRankingWrapper.classList.add('scoreboardRankingsWrapper');
// for each scoreBoardRanking in scoreBoardRankings, append
scoreBoardRankings.forEach((scoreBoardRanking) => {
scoreBoardRankingWrapper.appendChild(scoreBoardRanking);
});
dropdownContent.appendChild(scoreBoardRankingWrapper);
}
// Append menu tab title and arrow to menu tab.
menuTab.appendChild(menuTabTitle);
menuTab.appendChild(menuTabArrow);
// Append menu tab dropdown to menu tab.
menuTab.appendChild(dropdownContent);
const tabsContainer = document.querySelector('.mousehuntHeaderView-dropdownContainer');
if (! tabsContainer) {
return;
}
// Append as the second to last tab.
tabsContainer.insertBefore(menuTab, tabsContainer.lastChild);
};
const addBodyClass = () => {
const body = document.querySelector('.pageFrameView');
if (! body) {
return;
}
body.classList.add('no-sidebar');
};
addStyles(`/* Reflow grid for no sidebar */
.pageFrameView {
-ms-grid-columns: [first] auto [content-start] 760px [sidebar] 0 [content-end] auto [last];
grid-template-columns: [first] auto [content-start] 760px [sidebar] 0 [content-end] auto [last];
}
/* Sidebar moved into tab */
.pageFrameView.no-sidebar .pageSidebarView-user {
padding: 0 0 10px;
border-bottom: none;
}
.pageFrameView.no-sidebar .pageSidebarView {
display: none;
}
.pageFrameView.no-sidebar .mousehuntHeaderView .menuItem.sidebar.dropdown {
cursor: unset;
}
.pageFrameView.no-sidebar .mousehuntHeaderView .menuItem.sidebar .dropdownContent {
width: 365px;
/* 10px padding + 180px scoreboard + 5px gap + 180px scoreboard + 10px padding */
padding: 10px;
}
.pageFrameView.no-sidebar .mousehuntHeaderView .menuItem.sidebar .dropdownContent a {
display: unset;
height: auto;
padding: 0;
font-variant: none;
border-bottom: none;
}
.pageFrameView.no-sidebar .mousehuntHeaderView .menuItem.sidebar .dropdownContent a:hover,
.pageFrameView.no-sidebar .mousehuntHeaderView .menuItem.sidebar .dropdownContent a:focus {
text-decoration: underline;
background-color: unset;
}
/* Image */
.pageFrameView.no-sidebar .mousehuntHeaderView .menuItem.sidebar .dropdownContent a.pageSidebarView-user-image {
width: 30px;
height: 30px;
padding: 0;
background-repeat: no-repeat;
background-position: 50% 50%;
background-size: contain;
border: 1px solid #808080;
}
/* Name */
.pageFrameView.no-sidebar .mousehuntHeaderView .menuItem.sidebar .dropdownContent .pageSidebarView-user a:nth-child(2) {
display: inline;
padding: 0;
font-size: inherit;
font-variant: none;
color: #3b5998;
border-bottom: none;
}
/* <br> between name and logout */
.pageFrameView.no-sidebar .mousehuntHeaderView .menuItem.sidebar .dropdownContent .pageSidebarView-user br {
display: none;
}
/* Logout */
.pageFrameView.no-sidebar .mousehuntHeaderView .menuItem.sidebar .dropdownContent a.pageSidebarView-user-logout {
display: inline-block;
float: right;
height: auto;
padding: 5px 0;
margin-right: 10px;
font-size: inherit;
font-variant: none;
color: #3b5998;
border-bottom: none;
border-radius: 0;
}
.pageFrameView.no-sidebar .scoreboardRankingsWrapper {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 5px;
line-height: 14px;
}
.pageFrameView.no-sidebar .scoreboardRelativeRankingTableView-table {
padding-top: 5px;
background: #fff;
}
.pageFrameView.no-sidebar .mousehuntHeaderView .menuItem.sidebar .dropdownContent .scoreboardRankingsWrapper a {
font-size: 9px;
color: #3b5998;
text-decoration: none;
vertical-align: middle;
border-radius: 0;
}
.pageFrameView.no-sidebar .mousehuntHeaderView .menuItem.sidebar .dropdownContent .scoreboardRankingsWrapper a:hover,
.pageFrameView.no-sidebar .mousehuntHeaderView .menuItem.sidebar .dropdownContent .scoreboardRankingsWrapper a:focus {
text-decoration: underline;
}`);
addBodyClass();
onPageChange({ camp: { show: addBodyClass } });
onTravel(null, { callback: () => {
setTimeout(addBodyClass, 500);
} });
moveSidebar();
migrateUserscript('🐭️ MouseHunt - No Sidebar', 'https://greasyfork.org/en/scripts/449491-mousehunt-no-sidebar');
})());