Reddit Old Mobile 📱

Mobile-friendly design for Reddit Old

As of 12.12.2023. See ბოლო ვერსია.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name          Reddit Old Mobile 📱
// @description   Mobile-friendly design for Reddit Old
// @author        Agreasyforkuser
// @match         https://old.reddit.com/*
// @match         https://www.reddit.com/*
// @match         https://www.redditmedia.com/mediaembed/*
// @exclude       https://new.reddit.com/*
// @exclude-match https://old.reddit.com/chat/*
// @version       5.2
// @license       MIT
// @icon          https://www.redditstatic.com/desktop2x/img/favicon/android-icon-192x192.png
// @namespace     namespace example
// ==/UserScript==


if(window.location.hostname === 'old.reddit.com'){
    {
        const metaViewportElement = document.createElement('meta');
        metaViewportElement.setAttribute('name', 'viewport');
        metaViewportElement.setAttribute('content', 'width=device-width, initial-scale=1');
        document.head.appendChild(metaViewportElement);
    }

    {
        const styles = new CSSStyleSheet();
        // language=CSS
        styles.replaceSync(`
                html,


                #search input[type="text"] { border: none}
                /* Fix for search page */
                .combined-search-page #search input[type="text"] {border: 1px solid black;}
                #search {border-bottom: 2px solid rgb(206, 227, 248) !important;}

                .subscription-box:not(:hover) {opacity: 1}

                /* Expanded Media UNDER the post */
               .entry {overflow:visible;}

               /* Centering Expanded Video Posts */
               /* .expando {display: flex;flex-direction: column; align-items :center;} */
               .thing .media-preview-content, .thing .media-preview-content video {max-width:100%;height:auto !important}


               /* add some black */       
               body            {background: black !important}
               body > .content {background: white !important}
               #header         {background-color: black !important}
               .tabmenu li.selected a {color: black !important}
               .tabmenu li a          {color: white !important; opacity: 1 !important}
               .tabmenu li a:hover    {color: black !important}
               .reddit-video-player-root {background: black !important}
               #search                      {border-bottom: none !important}
               #search input[type="submit"] {filter: brightness(0)}
               .combined-search-page .search-submit-button {margin-left: 0px !important}

               /* Bigger Action Buttons, Spacing */
               .link .flat-list {font-size:large; text-align:center; margin-top:10px}
               .subreddit {font-size: large;}

               /* Border between Posts */
               .link {border-bottom:1px solid black;}
               .link { padding-left: 0;}


               /* Upvote Scores On Thumbnails */
               .midcol {background-color:rgba(0, 0, 0, 0.5); width:auto !important; border-radius:5px}
               .link .score                {color:white}
               .comments-page .link .score {color:black}
               .comments-page .midcol {background:none}
               .midcol {margin: 0}
               .link .midcol { position:absolute; z-index:999;font-size: x-small;}


               /* No Overlapping with Text-Only-Posts */
               .link .title {text-align: center;font-size:large; margin-bottom: 1px;}
               /* Centering this too for aesthetics */
               .tagline {text-align: center; margin-bottom: 3px;}


               /* Comment Page */
               .panestack-title { text-align:center}
               .commentarea .menuarea {text-align:center}
               #noresults {margin-right: 0px;text-align: center; opacity: 0.7}
               .comments-page .thumbnail {display:none !important}

               .link .reddit-profile-picture {display:none !important}


               /* Top Header */
               /* #header { border-bottom: 3px solid #cee3f8; border-bottom-right-radius: 15px; border-right: 1px solid #cee3f8; border-left: 1px solid #cee3f8; border-bottom-left-radius: 15px;} */
               #header               {border: none}
               #header-bottom-right  {position: initial !important}
               #sr-header-area:not(:hover)       {opacity:0 !important}

               .tabmenu li a         {padding: 0}


               .mobile-web-redirect-bar {display:none !important}



                body {
                    overflow-x: hidden;
                }
                .listing-chooser,
                #redesign-beta-optin-btn {
                    display: none;
                }
                #sr-header-area {
                    height: auto;
                }
                #sr-header-area .width-clip {
                    display: flex;
                }
                #sr-header-area .width-clip,
                #sr-header-area .sr-list,
                #sr-more-link,
                #header-bottom-right {position: inherit;}
                #sr-header-area .sr-list {
                    overflow: auto;
                }
                .tabmenu {
                    max-width: 100%;
                    overflow: auto;
                }
                .side {
                    z-index: 1001;
                    position: absolute;
                    top: 0;
                    left: 0;
                    margin: var(--header-height) 0 0 0;
                    width: 0;
                    overflow-x: hidden;
                }
                .side--active {
                    width: 100%;
                }
                .side--active ~ .content {
                    height: var(--sidebar-height);
                }
                .content {
                    margin: 0 !important;
                    width: 100% !important;
                    overflow-x: auto;
                    overflow-y: hidden;
                }
                .comments-page #siteTable .thing {
                    display: grid;
                    grid-template-columns: auto 1fr;
                    grid-template-areas:
                        'score thumbnail'
                        'main  main';
                    grid-gap: 5px;
                }
                .comments-page #siteTable .thing:not(:has(.thumbnail)) {
                    grid-template-areas:
                        'score main'
                        '.     main';
                }
                .comments-page #siteTable .thing .midcol {
                    grid-area: score;
                }
                .comments-page #siteTable .thing .thumbnail {
                    grid-area: thumbnail;
                }
                .comments-page #siteTable .thing .entry {
                    grid-area: main;
                }
                .comments-page #siteTable .thing .media-embed {
                    width: 100%;
                    height: auto;
                }
                .infobar,
                .searchpane,
                .wiki-page .wiki-page-content,
                .panestack-title,
                .commentarea .menuarea {
                    margin: 5px;
                }
                .commentarea .menuarea {
                    display: flex;
                }
                #search input[type=text],
                .roundfield,
                .formtabs-content {
                    width: 100%;
                }
                .subreddit .midcol {
                    width: auto !important;
                }
                .roundfield,
                .roundfield * {
                    box-sizing: border-box;
                }
                .roundfield input,
                .roundfield textarea,
                .roundfield select {
                    max-width: 100%;
                }
                .usertext,
                .menuarea {
                    overflow: auto;
                }
                .combined-search-page #search {
                    padding: 0;
                    display: grid;
                    grid-template-columns: 1fr auto;
                    grid-template-areas:
                        'query             submit'
                        'advanced          advanced'
                        'restrictSubreddit restrictSubreddit'
                        'nsfw              nsfw';
                }
                .combined-search-page #search input[type=text] {
                    grid-area: query;
                    min-width: auto;
                }
                .combined-search-page #search .search-submit-button {
                    grid-area: submit;
                }
                .combined-search-page #search label:has([name="restrict_sr"]) {
                    grid-area: restrictSubreddit;
                }
                .combined-search-page #search label:has([name="include_over_18"]) {
                    grid-area: nsfw;
                }
                .combined-search-page #search p:has(#search_showmore) {
                    grid-area: advanced;
                }
                .search-result-group {
                    width: 100% !important;
                    min-width: auto !important;
                    box-sizing: border-box;
                }
                .search-result-subreddit .search-result-meta {
                    padding: 0.5rem 0;
                    display: flex;
                    flex-direction: column;
                    row-gap: 0.5rem;
                }
                .search-result-subreddit .search-result-meta .stamp {
                    align-self: flex-start;
                }
                .search-link,
                .search-result-body a {
                    overflow-wrap: anywhere;
                    white-space: normal;
                }
            `);
        document.adoptedStyleSheets = [...document.adoptedStyleSheets, styles];
    }

    {
        const sidebarElement = document.querySelector('.side');
        if(sidebarElement){
            const
            menuElement = document.querySelector('.tabmenu'),
                  sidebarButtonContainerElement = document.createElement('li'),
                  sidebarButtonElement = document.createElement('a');
            sidebarButtonElement.textContent = 'sidebar';
            sidebarButtonElement.setAttribute('href', '#');
            sidebarButtonElement.addEventListener(
                'click',
                event => {
                    event.preventDefault();
                    const extraHeaderHeight = document.querySelector('.submit-page')
                    ? window.$('.content > h1').outerHeight(true) + window.$(menuElement).outerHeight(true) + 10
                    : 0;
                    document.documentElement.style.setProperty(
                        '--header-height',
                        `${window.$('#header').outerHeight(true) + extraHeaderHeight}px`
                    );
                    sidebarButtonContainerElement.classList.toggle(
                        'selected',
                        sidebarElement.classList.toggle('side--active')
                    );
                    document.documentElement.style.setProperty(
                        '--sidebar-height',
                        `${sidebarElement.offsetHeight + extraHeaderHeight}px`
                    );
                }
            );
            sidebarButtonContainerElement.appendChild(sidebarButtonElement);
            menuElement.appendChild(sidebarButtonContainerElement);
        }
    }
}
else if(window.location.hostname === 'www.redditmedia.com'){
    const styles = new CSSStyleSheet();
    // language=CSS
    styles.replaceSync(`
            .embedly-embed {
                width: 100%;
            }
        `);
    document.adoptedStyleSheets = [...document.adoptedStyleSheets, styles];
}


///////////////////////////////////// hide logo on frontpages /////////////////////////////////////////////////////////////////

if (window.location.href === 'https://old.reddit.com'||
    window.location.href === 'https://old.reddit.com/'||
    window.location.href.includes('https://old.reddit.com/new/')||
    window.location.href.includes('https://old.reddit.com/controversial/')||
    window.location.href.includes('https://old.reddit.com/hot/')||
    window.location.href.includes('https://old.reddit.com/top/')||
    window.location.href.includes('https://old.reddit.com/rising/'))
{
    document.getElementById('header-img').remove();
}

////////////////////////// Move Searchbar, make some space on the Comments Page//////////////////////////////////////////////////

var excludedPattern = /https:\/\/.*\.reddit\.com\/.*\/comments\/.*/;
if (!excludedPattern.test(window.location.href) ) {
    // Get the search form element

    var searchForm = document.getElementById('search');

    // Get the tab menu element
    var tabMenu = document.querySelector('.tabmenu');

    // Move the search form to the right of the tab menu
    if (searchForm && tabMenu) {
        tabMenu.parentNode.insertBefore(searchForm, tabMenu.nextSibling);
    }
}

// if (excludedPattern.test(window.location.href)) {
//     // Select the element with the ID "header-bottom-right"
//     var headerBottomRight = document.getElementById('header-bottom-right');

//     // Check if the element exists
//     if (headerBottomRight) {
//         // Remove the element from its parent element
//         headerBottomRight.parentNode.removeChild(headerBottomRight);
//     }
// }

/////////////////////Toggle Top Header On Scroll /////////////////////////////////////////////////////////////


// 'use strict';

// var header = document.getElementById('header');
// var headerHeight = header.offsetHeight;
// var lastScrollTop = 0;

// if (header) {
//     header.style.position = 'fixed';
//     header.style.top = '0';
//     header.style.zIndex = '1100';
//     header.style.width = '100%';
//     document.body.style.paddingTop = headerHeight + 'px';

//     window.addEventListener('scroll', function() {
//         var scrollTop = window.pageYOffset || document.documentElement.scrollTop;

//         if (scrollTop > lastScrollTop) {
//             // Scrolling down
//             header.style.opacity = '0';
//         } else {
//             // Scrolling up
//             header.style.opacity = '.91';

//             if (scrollTop > 0) {
//                 // Move header 45% of its height upwards
//                 var moveAmount = Math.round(0.45 * headerHeight);
//                 header.style.top = (-moveAmount) + 'px';
//             } else {
//                 // At the top, reset header
//                 header.style.top = '0';
//                 header.style.opacity = '1';
//             }
//         }

//         lastScrollTop = scrollTop;
//     });
// }