Reddit Old Mobile 📱

Mobile-friendly design for Reddit Old

安装此脚本?
作者推荐脚本

您可能也喜欢Reddit CSS

安装此脚本
  1. // ==UserScript==
  2. // @name Reddit Old Mobile 📱
  3. // @description Mobile-friendly design for Reddit Old
  4. // @author Agreasyforkuser
  5. // @match https://old.reddit.com/*
  6. // @match https://www.reddit.com/*
  7. // @match https://www.redditmedia.com/mediaembed/*
  8. // @exclude https://new.reddit.com/*
  9. // @exclude-match https://old.reddit.com/chat/*
  10. // @version 6.0
  11. // @license MIT
  12. // @icon https://www.redditstatic.com/desktop2x/img/favicon/android-icon-192x192.png
  13. // @namespace tampermonkey
  14. // ==/UserScript==
  15.  
  16. if(window.location.hostname === 'old.reddit.com'){
  17. {
  18. const metaViewportElement = document.createElement('meta');
  19. metaViewportElement.setAttribute('name', 'viewport');
  20. metaViewportElement.setAttribute('content', 'width=device-width, initial-scale=1');
  21. document.head.appendChild(metaViewportElement);
  22. }
  23. {
  24. const styles = new CSSStyleSheet();
  25. // language=CSS
  26. styles.replaceSync(`html,
  27. body {background: var(--theme-color-new) !important}
  28. body > .content {background: white !important}
  29.  
  30. #search {margin-left: 5px; margin-right: 5px}
  31. #search input[type="text"] {border-color: var(--theme-color-new) !important}
  32. #search input[type="text"] {border-radius: 15px}
  33. .combined-search-page #search input[type="text"] {border-color: black !important}
  34.  
  35. /* Top Header */
  36. #header {border: none}
  37. #header-bottom-right {border: none; position: initial !important}
  38. #header-bottom-left {padding-left: 0 !important}
  39. /* hide scrollbar */
  40. #sr-header-area .sr-list {overflow: hidden !important}
  41.  
  42.  
  43.  
  44. /* Search and fixes for search page */
  45. .combined-search-page .searchpane {padding-left: 0px}
  46. .search-result-group {padding-left: 10px; padding-right: 10px}
  47. .combined-search-page .search-submit-button {margin-left: 0px !important}
  48. .combined-search-page .subreddit-icon {display: none}
  49. .combined-search-page #sr-header-area {display: none}
  50.  
  51. /* Expanded Media UNDER the post */
  52. .entry {overflow:visible;}
  53.  
  54. /* Centering Expanded Video Posts */
  55. .thing .media-preview-content, .thing .media-preview-content video {max-width: 100%; height: auto !important}
  56.  
  57. /* Centered Action Buttons */
  58. .link .flat-list {text-align:center}
  59. /* Centering this too for aesthetics */
  60. .link .tagline {text-align: center}
  61. .link .tagline {margin-bottom: 10px; margin-top: 10px}
  62. .comments-page .link .tagline {margin-bottom: unset; margin-top: unset}
  63.  
  64. /* Border between Posts */
  65. .link {border-bottom:1px solid black}
  66. .link {padding-left: 0}
  67. .linklisting .md {margin-bottom: 0px}
  68.  
  69.  
  70. /* Upvote Scores On Thumbnails */
  71. .midcol {margin: 0}
  72. .link .midcol {background-color:rgba(0, 0, 0, 0.6); width:auto !important}
  73. .link .midcol {position: absolute; z-index:999; font-size: x-small}
  74. .comments-page .link .midcol {background: none}
  75. .link .arrow {filter: brightness(100)}
  76. .comments-page .link .arrow {filter: none !important}
  77. .arrow.upmod, .arrow.downmod {filter: none !important}
  78. .link .score {color: white}
  79. .comments-page .link .score {color: #c6c6c6}
  80. .comments-page .link .title {margin-left: 5px; margin-right: 0}
  81.  
  82.  
  83.  
  84. /* No Overlapping with Text-Only-Posts */
  85. .link .title {text-align: center;font-size:large; margin-bottom: 1px; margin-right: 0 !important}
  86. .link .reddit-profile-picture {display:none !important}
  87.  
  88.  
  89. /* Comment Page */
  90. .comments-page #sr-header-area {display:none}
  91. .panestack-title {text-align:center}
  92. #noresults {margin-right: 0px !important; text-align: center}
  93. .comments-page .thumbnail {display:none !important}
  94. .commentarea .menuarea {display: flow-root !important; text-align: center}
  95. .comments-page .menuarea .spacer {margin-right: 0}
  96. .comments-page .dropdown.lightdrop .selected {padding-right: 0}
  97. /* bigger posts, title gets the whole page width */
  98. /* firefox */
  99. .comments-page .entry {width: -moz-available !important}
  100. /* chromium */
  101. .comments-page .entry {width: -webkit-fill-available !important}
  102. .comments-page .expando-button.expanded {opacity: 0}
  103. .comments-page .expando-button {margin: 0}
  104.  
  105.  
  106. /* error messages */
  107. .comments-page #noresults {display: none}
  108. #noresults {margin-right: 0px !important; text-align: center}
  109.  
  110.  
  111. /* gallery navbar */
  112. .media-gallery .gallery-nav-back {padding:0}
  113.  
  114. /* Navbar */
  115. .nav-buttons {width:98%;border-top-right-radius: 50px !important; border-top-left-radius: 50px !important}
  116. .nextprev a {display:inline-block;width:49%; padding:0 !important}
  117. .nextprev .separator {display:none}
  118.  
  119.  
  120.  
  121. /* Give the page a "mobile"-feel */
  122. .pagename {border-radius: 5px}
  123. .tabmenu li a {border-radius: 5px; padding: 0}
  124. #header img, .subreddit-icon, .reddit-profile-picture {border-radius: 5px}
  125. .entry .buttons li {border-radius: 5px !important}
  126. .expando-button.selftext {border-radius: 5px !important}
  127.  
  128.  
  129.  
  130. .subscription-box:not(:hover) {opacity: 1}
  131.  
  132. body {
  133. overflow-x: hidden;
  134. }
  135. .listing-chooser,
  136. #redesign-beta-optin-btn {
  137. display: none;
  138. }
  139. #sr-header-area {
  140. height: auto;
  141. }
  142. #sr-header-area .width-clip {
  143. display: flex;
  144. }
  145. #sr-header-area .width-clip,
  146. #sr-header-area .sr-list,
  147. #sr-more-link,
  148. #header-bottom-right {position: inherit;}
  149. #sr-header-area .sr-list {
  150. overflow: auto;
  151. }
  152. .tabmenu {
  153. max-width: 100%;
  154. overflow: auto;
  155. }
  156. .side {
  157. z-index: 1001;
  158. position: absolute;
  159. top: 0;
  160. left: 0;
  161. margin: var(--header-height) 0 0 0;
  162. width: 0;
  163. overflow-x: hidden;
  164. }
  165.  
  166. /* fix for custom subreddit styles */
  167. .side {opacity:0}
  168. .side--active {opacity:1}
  169.  
  170. .side--active {
  171. width: 100%;
  172. }
  173. .side--active ~ .content {
  174. height: var(--sidebar-height);
  175. }
  176. .content {
  177. margin: 0 !important;
  178. width: 100% !important;
  179. overflow-x: auto;
  180. overflow-y: hidden;
  181. }
  182. .comments-page #siteTable .thing {
  183. display: grid;
  184. grid-template-columns: auto 1fr;
  185. grid-template-areas:
  186. 'score thumbnail'
  187. 'main main';
  188. grid-gap: 5px;
  189. }
  190. .comments-page #siteTable .thing:not(:has(.thumbnail)) {
  191. grid-template-areas:
  192. 'score main'
  193. '. main';
  194. }
  195. .comments-page #siteTable .thing .midcol {
  196. grid-area: score;
  197. }
  198. .comments-page #siteTable .thing .thumbnail {
  199. grid-area: thumbnail;
  200. }
  201. .comments-page #siteTable .thing .entry {
  202. grid-area: main;
  203. }
  204. .comments-page #siteTable .thing .media-embed {
  205. width: 100%;
  206. height: auto;
  207. }
  208. .infobar,
  209. .searchpane,
  210. .wiki-page .wiki-page-content,
  211. .panestack-title,
  212. .commentarea .menuarea {
  213. margin: 5px;
  214. }
  215. /* comment this out because of centering */
  216. /*.commentarea .menuarea {display: flex}*/
  217. #search input[type=text],
  218. .roundfield,
  219. .formtabs-content {
  220. width: 100%;
  221. }
  222. .subreddit .midcol {
  223. width: auto !important;
  224. }
  225. .roundfield,
  226. .roundfield * {
  227. box-sizing: border-box;
  228. }
  229. .roundfield input,
  230. .roundfield textarea,
  231. .roundfield select {
  232. max-width: 100%;
  233. }
  234. .usertext,
  235. .menuarea {
  236. overflow: auto;
  237. }
  238. .combined-search-page #search {
  239. padding: 0;
  240. display: grid;
  241. grid-template-columns: 1fr auto;
  242. grid-template-areas:
  243. 'query submit'
  244. 'advanced advanced'
  245. 'restrictSubreddit restrictSubreddit'
  246. 'nsfw nsfw';
  247. }
  248. .combined-search-page #search input[type=text] {
  249. grid-area: query;
  250. min-width: auto;
  251. }
  252. .combined-search-page #search .search-submit-button {
  253. grid-area: submit;
  254. }
  255. .combined-search-page #search label:has([name="restrict_sr"]) {
  256. grid-area: restrictSubreddit;
  257. }
  258. .combined-search-page #search label:has([name="include_over_18"]) {
  259. grid-area: nsfw;
  260. }
  261. .combined-search-page #search p:has(#search_showmore) {
  262. grid-area: advanced;
  263. }
  264. .search-result-group {
  265. width: 100% !important;
  266. min-width: auto !important;
  267. box-sizing: border-box;
  268. }
  269. .search-result-subreddit .search-result-meta {
  270. padding: 0.5rem 0;
  271. display: flex;
  272. flex-direction: column;
  273. row-gap: 0.5rem;
  274. }
  275. .search-result-subreddit .search-result-meta .stamp {
  276. align-self: flex-start;
  277. }
  278. .search-link,
  279. .search-result-body a {
  280. overflow-wrap: anywhere;
  281. white-space: normal;
  282. }
  283. `);
  284. document.adoptedStyleSheets = [...document.adoptedStyleSheets, styles];
  285. }
  286.  
  287. {
  288. const sidebarElement = document.querySelector('.side');
  289. if(sidebarElement){
  290. const
  291. menuElement = document.querySelector('.tabmenu'),
  292. sidebarButtonContainerElement = document.createElement('li'),
  293. sidebarButtonElement = document.createElement('a');
  294. sidebarButtonElement.textContent = 'sidebar';
  295. sidebarButtonElement.setAttribute('href', '#');
  296. sidebarButtonElement.addEventListener(
  297. 'click',
  298. event => {
  299. event.preventDefault();
  300. const extraHeaderHeight = document.querySelector('.submit-page')
  301. ? window.$('.content > h1').outerHeight(true) + window.$(menuElement).outerHeight(true) + 10
  302. : 0;
  303. document.documentElement.style.setProperty(
  304. '--header-height',
  305. `${$('#header').outerHeight(true) + extraHeaderHeight}px`
  306. // this doesn't work on Firefox browsers:
  307. //`${window.$('#header').outerHeight(true) + extraHeaderHeight}px`
  308. );
  309. sidebarButtonContainerElement.classList.toggle(
  310. 'selected',
  311. sidebarElement.classList.toggle('side--active')
  312. );
  313. document.documentElement.style.setProperty(
  314. '--sidebar-height',
  315. `${sidebarElement.offsetHeight + extraHeaderHeight}px`
  316. );
  317. }
  318. );
  319. sidebarButtonContainerElement.appendChild(sidebarButtonElement);
  320. menuElement.appendChild(sidebarButtonContainerElement);
  321. }
  322. }
  323. }
  324. else if(window.location.hostname === 'www.redditmedia.com'){
  325. const styles = new CSSStyleSheet();
  326. // language=CSS
  327. styles.replaceSync(`
  328. .embedly-embed {
  329. width: 100%;
  330. }
  331. `);
  332. document.adoptedStyleSheets = [...document.adoptedStyleSheets, styles];
  333. }
  334.  
  335. ////////////////////////// Move Searchbar, make some space on the Comments Page//////////////////////////////////////////////////
  336. var excludedPattern = /https:\/\/.*\.reddit\.com\/.*\/comments\/.*/;
  337. if (!excludedPattern.test(window.location.href) ) {
  338. // Get the search form element
  339.  
  340. var searchForm = document.getElementById('search');
  341.  
  342. // Get the tab menu element
  343. var tabMenu = document.querySelector('.tabmenu');
  344.  
  345. // Move the search form to the right of the tab menu
  346. if (searchForm && tabMenu) {
  347. tabMenu.parentNode.insertBefore(searchForm, tabMenu.nextSibling);
  348. }
  349. };
  350. ///////////////// remove "view more:" text from navbar //////////////////////////////////
  351. var nextPrevSpan = document.querySelector("span.nextprev");
  352. if (nextPrevSpan){nextPrevSpan.firstChild.nodeValue = ""}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址