Skip to content

Commit 69a07c1

Browse files
committed
Add show/hide nav button and other styling tweaks
1 parent 0cde67a commit 69a07c1

4 files changed

Lines changed: 112 additions & 14 deletions

File tree

_includes/greasemonkey/sa-mobile-friendly/sa-mobile-friendly.css

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,75 @@
88
box-sizing: border-box;
99
}
1010

11+
/* Nav button from js */
12+
13+
.sa-mobile-friendly-menu-button {
14+
text-indent: 100%;
15+
overflow: hidden;
16+
position: absolute;
17+
right: 0;
18+
top: 0;
19+
height: 32px;
20+
width: 32px;
21+
box-shadow: none;
22+
border-top: none;
23+
border-right: none;
24+
25+
&:before {
26+
text-indent: 0;
27+
display: block;
28+
content: "☰";
29+
left: 0;
30+
top: 0;
31+
width: 100%;
32+
height: 100%;
33+
text-align: center;
34+
line-height: 2.1;
35+
}
36+
}
37+
38+
/* Mobile friendly styling */
39+
1140
* {
12-
max-width:100%;
41+
max-width: 100%;
42+
}
43+
44+
body {
45+
background-image: none !important;
46+
47+
&:not(.sa-mobile-friendly-menu-button-clicked) {
48+
#nav_purchase,
49+
#navigation,
50+
#threadiklist,
51+
.bottom_forms,
52+
.threadrate,
53+
.navigation {
54+
display: none !important;
55+
}
56+
}
57+
58+
&.sa-mobile-friendly-menu-button-clicked {
59+
#container {
60+
padding-top: 32px;
61+
}
62+
63+
.sa-mobile-friendly-menu-button:before {
64+
content: "✖";
65+
}
66+
}
1367
}
1468

1569
#container {
1670
padding: 0 0 5px 0;
17-
}
1871

19-
#nav_purchase,
20-
#navigation,
21-
#threadiklist,
22-
.bottom_forms,
23-
.threadrate,
24-
.navigation {
25-
display: none !important;
72+
.breadcrumbs:first-child .bclast {
73+
padding-right: 37px;
74+
}
2675
}
2776

2877
#nav_title {
29-
padding: 0 5px;
78+
padding: 5px 37px 5px 5px;
79+
line-height: 32px;
3080

3181
div {
3282
display: inline-block;
@@ -56,6 +106,10 @@ div.pages span.disabled, .letternav li a,
56106
white-space: normal !important;
57107
line-height: 1.5;
58108
}
109+
110+
.up span {
111+
display: none !important;
112+
}
59113

60114
.index {
61115
display: none !important;
@@ -166,13 +220,14 @@ div.pages span.disabled, .letternav li a,
166220
}
167221

168222
.postdate {
169-
background: none !important;
223+
background-image: none !important;
170224
border: none !important;
171225
padding-right: 10px;
226+
flex-grow: 1;
172227
}
173228

174229
.postlinks {
175-
background: none !important;
230+
background-image: none !important;
176231
flex-grow: 1;
177232
text-align: right;
178233
}
@@ -209,7 +264,8 @@ div.pages span.disabled, .letternav li a,
209264
}
210265

211266
.registered,
212-
.special_title {
267+
.special_title,
268+
.special_title_v2 {
213269
display: none;
214270
}
215271

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.5
1+
0.1.6

greasemonkey/sa-mobile-friendly/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ <h2><a href="#description">Usage and description</a></h2>
1212
<h3>Versions</h3>
1313

1414
<ul>
15+
<li>
16+
0.1.6 - 2025-10-27
17+
<ul>
18+
<li>Hide special title v2</li>
19+
<li>Fix date/edit/quote background color</li>
20+
<li>Adding show/hide nav button</li>
21+
</ul>
22+
</li>
1523
<li>
1624
0.1.5 - 2025-10-26
1725
<ul>

greasemonkey/sa-mobile-friendly/sa-mobile-friendly.user.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
(function() {
66
'use strict';
77

8+
// Add mobile stylesheet
89
const style = document.createElement("STYLE");
910
style.textContent = `{% include greasemonkey/sa-mobile-friendly/sa-mobile-friendly.css %}`;
1011

1112
document.documentElement.append(style);
1213

14+
// Add mobile meta tag
1315
function addMeta() {
1416
const head = document.querySelector('head');
1517
const meta = document.createElement('meta');
@@ -29,4 +31,36 @@
2931
}
3032

3133
tryAddMeta();
34+
35+
// Add mobile menu button
36+
let $container = null;
37+
const bodyOpenClass = 'sa-mobile-friendly-menu-button-clicked';
38+
39+
function addMobileButton() {
40+
const $button = document.createElement('BUTTON');
41+
$button.className = 'sa-mobile-friendly-menu-button';
42+
$button.textContent = 'Show Navigation';
43+
44+
$button.addEventListener('click', () => {
45+
if (document.body.classList.contains(bodyOpenClass)) {
46+
document.body.classList.remove(bodyOpenClass);
47+
} else {
48+
document.body.classList.add(bodyOpenClass);
49+
}
50+
});
51+
52+
$container.prepend($button);
53+
}
54+
55+
function tryAddMobileButton() {
56+
$container = document.querySelector('#container');
57+
58+
if ($container) {
59+
addMobileButton();
60+
} else {
61+
setTimeout(tryAddMeta, 100);
62+
}
63+
}
64+
65+
tryAddMobileButton();
3266
})();

0 commit comments

Comments
 (0)