Reddit CSS

Bigger Thumbnails and Clicking Functionality

Stan na 04-07-2023. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Reddit CSS
// @namespace    https://www.reddit.com
// @version      2.4
// @description  Bigger Thumbnails and Clicking Functionality
// @author       Agreasyforkuser
// @match        https://*.reddit.com/*
// @icon         https://www.redditstatic.com/desktop2x/img/favicon/android-icon-192x192.png
// @license      MIT
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // Define the CSS to enlarge the thumbnails and modify the styling
    var customCSS = `
        /* Video Controls for Mobile */
        video::-webkit-media-controls-panel {background: none; opacity:.6}
        video::-webkit-media-controls-overlay-play-button {opacity: 0;}

        /* Flair Labels */
        .flairrichtext {border-radius: 20px;}
        .linkflairlabel {border-radius: 5px;}

        /* Subreddit Name */
        body.with-listing-chooser #header .pagename {position:inherit; color: white}
        .pagename a {color: black; margin-left:4px; margin-right:4px}
        .pagename {background-color:white; border-radius:5px}

        /* Increase the width and height of the thumbnail */
        .thumbnail img {
            width: 180px !important;
            height: 180px !important;
        }

        /* Adjust the size of the thumbnail container */
        .thumbnail {
            width: 180px !important;
            height: 180px !important;
            position: relative;
            margin-bottom: 0;
        }

        /* Post */
        .thing .title {font-weight: normal;color: #000; ;margin-bottom: 15px;}
        .subreddit {font-weight: bold;font-size: larger;color: #000;}
        .link .flat-list {font-size:larger}
        .link.last-clicked {border: 3px dotted red;}

        /* Text Posts Background*/
        .link .usertext-body .md {background: none; border: 1px dotted gray}

        /* Post Details */
        .entry .buttons li a {color:#000000c7; font-weight:normal}
        .entry .buttons li   {background: #0000000d;border-radius: 10px;}
        .stamp {background-color:white; font-weight: bold}
        .tagline {color: #8880; margin-bottom: 15px;}
        .tagline .live-timestamp {color: #369}
        .domain {display: none;}
        .reportbtn {display:none}
        .post-crosspost-button {display:none}
        .post-sharing-button {display:none}
        .buttons .give-gold.gold-give-gold {display: none}
        .expando-button {opacity:0.5}


        /* Header Font Size and Icon */
        #header-bottom-left {font-size: large;}
        #header-img.default-header:not(:hover) {opacity: 0.05}
        /* Hide Username */
        .user:not(:hover) {opacity: 0;}
        #header-bottom-right:not(:hover) {background: none}
        #header-bottom-right {font-size: larger;}
        #header {border-bottom: 3px solid #5f99cf;}
        #header-bottom-left {margin-top: -10px;}


        /* Upper Bars */
        #sr-header-area:not(:hover) {background: none !important;border-bottom: none; opacity:0.3 }
        #sr-header-area:not(:hover) .redesign-beta-optin {opacity: 0}
        .separator {color: transparent;}
        #header-bottom-left {margin-top: -10px;}
        a[href="https://old.reddit.com/wiki/"].choice {display: none;}
        .tabmenu li a          {background:none;opacity:0.6;font-weight: normal;}
        .tabmenu li.selected a {opacity:1;font-weight: bold;font-size: x-large; background-color: white; border: 3px solid #5f99cf;border-bottom-color: rgb(95, 153, 207);border-bottom-style: solid;border-bottom-width: 3px;border-bottom: 3px solid white;}
        .tabmenu li.selected a {border-top-right-radius: 5px;border-top-left-radius: 5px;}




        /* Sidebar */
        .sidecontentbox .content {border: none}
        .premium-banner {display:none}
        .login-form-side {border-radius: 5px;}

        /* Search */
        #search input[type="text"] {border-radius:5px}
        #searchexpando {border-radius:9px}

        /* Videoplayer Background */
        .reddit-video-player-root {background: #0000;}

        /* Video Duration Info */
        .duration-overlay {font-size: 10pt; font-weight: bold;}
        .duration-overlay {border-top-left-radius: 50px;border-top-right-radius: 50px;}

        /* Space between Posts */
        .link {margin-bottom: 0px;}

        /* Expanded Post Margins */
        .expando {margin: 0}

        /* Gallery Buttons */
        .media-gallery .gallery-nav-bar {font-size:large}


        /* Rank / Scores */
        .link .rank {display: none}
        .arrow.up {display: none}
        .arrow.down {display: none}

        /* Comment Page */
        .panestack-title { padding-bottom: 0px; border-bottom: none;}
        .commentarea .menuarea {font-size: large;}
        .comment .author {font-size: larger;float:left}
        .comment .expand {font-size: large;float:left; opacity:1}
        .comment .expand:not(:hover) { opacity:0.1}
        .commentarea > .usertext:not(:hover) {opacity:0.3; height: 20px}
        .commentarea .entry .buttons:not(:hover) {opacity:0;}
        .comments-page #siteTable .thing {display: flex !important;border: none;}
        .comment .tagline {color: #00000069 ; margin-bottom: 15px; text-align:left}
        .comment .child {border-left: dotted 3px #000000}
        .comment .score {font-size: larger}
        .comments-page .arrow.up {display:block}
        .comments-page .arrow.down {display:block}
        .comments-page .thumbnail {display:none}

        /* Bottom Page */
        .footer {display:none}
        .footer-parent {display:none}
        .debuginfo {display:none}
        .bottommenu {opacity:0}

        /* Navbar */
        .nav-buttons {
         display:table;
         bottom: 0 !important;
         right: 0 !important;
         text-align: center !important;
         border: 3px solid;
         border-color: #cee3f8;
         border-radius: 10px;
         background-color: #cee3f8;
         font-size: larger;
         z-index: 9998 !important;
         }
         .nextprev a {background:none !important}



    `;

    // Add the custom CSS to the page
    GM_addStyle(customCSS);

////////////////////// Remove thumbnails from posts without thumbnails////////////////////////

    function removePostsWithoutImages() {
        var posts = document.querySelectorAll('.thumbnail');
        for (var i = 0; i < posts.length; i++) {
            if (!posts[i].querySelector('img')) {
                posts[i].parentNode.removeChild(posts[i]);
            }
        }
    }
    setInterval(removePostsWithoutImages, 1000);
})();


///////////////////////// Show all post options on comments page /////////////////////////////

var excludedPattern = /https:\/\/.*\.reddit\.com\/.*\/comments\/.*/;
if (excludedPattern.test(window.location.href)) {
    GM_addStyle(`.reportbtn                         {display:block}
                 .post-crosspost-button             {display:block}
                 .post-sharing-button               {display:block}
                 .buttons .give-gold.gold-give-gold {display: block}
                 .expando-button                    {opacity: 1 }   `);
}


/////////////////////////////////////////////////Thumbnail Click Functionality //////////////////

// Custom CSS for the clicked thumbnail
const customCSS = `
  /* Makes Clicking Easier */
  .thumbnail {z-index:99}

  .thumbnail.clicked {
    width: 80px !important;
    height: 80px !important;
    border-top-right-radius: 15px;
    border-bottom-right-radius: 15px;
  }

  .thumbnail.clicked img {
    width: 80px !important;
    height: 80px !important;
  }

  .thing.clicked .arrow.up {display: block}
  .thing.clicked .arrow.down {display:block}
`;

function expandPostOnElementClick(element) {
  const expandoButton = element.closest('.thing').querySelector('.expando-button');

  if (expandoButton) {
    expandoButton.click();
  }
}

function handleElementClick(event) {
  event.stopPropagation();
  event.preventDefault();

  const element = event.currentTarget;
  const thumbnail = element.closest('.thumbnail');
  const thing = element.closest('.thing');

  // Check if the thumbnail has the 'clicked' class
  const isClicked = thumbnail.classList.contains('clicked');

  if (isClicked) {
    // Remove the 'clicked' class to revert the changes
    thumbnail.classList.remove('clicked');
    thing.classList.remove('clicked');
  } else {
    // Add 'clicked' class to the thumbnail
    thumbnail.classList.add('clicked');
    thing.classList.add('clicked');
  }

  expandPostOnElementClick(element);
}

function attachClickListenersToElements() {
  const elements = document.querySelectorAll('.thumbnail, img[src*="external-preview.redd.it"]');

  elements.forEach((element) => {
    element.addEventListener('click', handleElementClick);
  });
}

// Add custom CSS styles
GM_addStyle(customCSS);

// Attach click listeners to elements initially
attachClickListenersToElements();

// Create a MutationObserver to monitor the page for changes
const observer = new MutationObserver(() => {
  // Attach click listeners to elements whenever new content is added to the page
  attachClickListenersToElements();
});

// Start observing the document for changes
observer.observe(document, { childList: true, subtree: true });

/////////////////////Toggle Nav-Bar On Scroll /////////////////////////////////////////////////////////////


'use strict';

var navButtons = document.getElementsByClassName('nav-buttons');
if (navButtons.length > 0) {
  var nav = navButtons[0];
  nav.style.position = 'fixed';
}

//var headerHeight = header.offsetHeight;
var lastScrollTop = 0;


window.addEventListener('scroll', function() {
  var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
  var windowHeight = window.innerHeight;
  var documentHeight = document.documentElement.scrollHeight;

  if (scrollTop === 0) {
    // Reached the top of the page
    nav.style.opacity = '1';
    nav.style.pointerEvents = 'auto';
    } else {
      // Scrolling up
      nav.style.opacity = '.8';
      nav.style.pointerEvents = 'auto';
    }

  if (scrollTop + windowHeight >= documentHeight) {
    // Reached the end of the page
    nav.style.opacity = '1';
    nav.style.pointerEvents = 'auto';
    } else {
    if (scrollTop > lastScrollTop) {
      // Scrolling down
      nav.style.opacity = '0';
      nav.style.pointerEvents = 'none';
    } 
  }

  lastScrollTop = scrollTop;
});


/////////////////////////grey out post-buttons if no comments were written /////////////////////////////////
(function() {

    var excludedPattern = /https:\/\/.*\.reddit\.com\/.*\/comments\/.*/; //dont grey out on comment page
    if (!excludedPattern.test(window.location.href)) {

    'use strict';

    const removeCommentsCount = element => {
        const text = element.textContent.trim();
        if (!isNaN(parseInt(text.charAt(0), 10))) return;
        element.closest('ul.flat-list.buttons').style.opacity = '0.2';
    };

    const commentElements = document.querySelectorAll('a.comments');
    commentElements.forEach(removeCommentsCount);

    const observer = new MutationObserver(mutationsList => {
        for (const mutation of mutationsList) {
            if (mutation.type === 'childList') {
                const newCommentElements = mutation.addedNodes;
                newCommentElements.forEach(node => {
                    if (node instanceof HTMLElement) {
                        const element = node.querySelector('a.comments');
                        if (element) removeCommentsCount(element);
                    }
                });
            }
        }

    });

    observer.observe(document.body, { childList: true, subtree: true }); }
})();