Advertisement
Guest User

Vuniper theme for Metacritic

a guest
Dec 1st, 2024
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 5.15 KB | Source Code | 0 0
  1. // ==UserScript==
  2. // @name         Inject CSS to Metacritic
  3. // @namespace    http://tampermonkey.net/
  4. // @version      1.0
  5. // @description  Add custom CSS to Metacritic, so it looks like Vuniper
  6. // @author       Speckart
  7. // @match        https://www.metacritic.com/*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. (function () {
  12.   'use strict';
  13.  
  14.  
  15.   const customCSS = `
  16.  
  17.   body {
  18.     background-color: #161616;
  19.     padding-bottom: 64px;
  20.   }
  21.  
  22.   /* The top ad bar */
  23.   .c-adSkyBox.rendered{
  24.     display:none;
  25.   }
  26.  
  27.   /* Nav bar elements except the search input */
  28.   .c-siteLogo,
  29.   .c-siteHeaderDesktopContainer nav,
  30.     button.c-userRegisterButton {
  31.     display:none !important;
  32.   }
  33.  
  34.   /* Center the search input */
  35.   .c-siteHeaderDesktopContainer {
  36.     justify-content: center;
  37.   }
  38.  
  39.   header.c-siteHeader {
  40.     max-height: 56px;
  41.   }
  42.  
  43.   /* Search input container */
  44.   .c-siteHeaderDesktopContainer div.u-flexbox {
  45.     max-width: 500px;
  46.   }
  47.  
  48.   .c-searchBox {
  49.     background-color: #161616;
  50.     border: none;
  51.     border-radius: 20px;
  52.   }
  53.  
  54.   .c-searchBox input {
  55.     color: white;
  56.     padding-left: 8px;
  57.   }
  58.  
  59.   .c-searchBox svg {
  60.     display:none;
  61.   }
  62.  
  63.   /* Logo overrides */
  64.   .c-globalPageTitle {
  65.     display: flex;
  66.     justify-content: center;
  67.   }
  68.  
  69.   .c-globalPageTitle_container {
  70.   background-image: url(https://vuniper.com/icons/app-logo.png);
  71.     width: 67px;
  72.     height: 56px;
  73.     transform: scale(0.65);
  74.   }
  75.  
  76.   .c-globalPageTitle_container_colorOverlay,
  77.   .c-globalPageTitle_seoTitle,
  78.   .c-globalPageTitle_container .c-cmsImage,
  79.   .c-globalPageTitle_description {
  80.     display:none;
  81.   }
  82.  
  83.   /* End logo overrides */
  84.  
  85.   .c-globalCarousel {
  86.     width: 1000px;
  87.   }
  88.  
  89.   h2.c-globalHeader_titleText {
  90.     color: #dc6ef8;
  91.     font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
  92.     font-weight: 400;
  93.     text-shadow: 0 0 5px rgb(243 45 228 / 50%),
  94.       0 0 10px rgb(239 62 234 / 30%), 0 0 15px rgb(255 0 212 / 20%),
  95.       0 0 20px rgb(251 0 255 / 10%);
  96.   }
  97.  
  98.   a.c-globalHeader_viewMore {
  99.     text-decoration: none !important;
  100.     position: relative;
  101.     top: 6px;
  102.   }
  103.  
  104.   /* Removes the underline from the section headings*/
  105.   .c-globalHeader_heading {
  106.     border: none;
  107.   }
  108.  
  109.   .c-globalHeader.c-globalCarousel_header {
  110.     margin-bottom: 12px;
  111.   }
  112.  
  113.   h3.c-globalProductCard_title {
  114.     color: white;
  115.     text-decoration: none;
  116.     font-weight: 500;
  117.     font-size: 14px;
  118.     font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
  119.   }
  120.  
  121.   .c-globalCarousel_content {
  122.     gap: 24px !important;
  123.   }
  124.  
  125.   .c-globalCarousel_fade-left:after,
  126.   .c-globalCarousel_fade-right:before {
  127.     display:none;
  128.   }
  129.  
  130.   .c-globalProductCard_imgContainer {
  131.     width: 180px !important;
  132.     height: 266px !important;
  133.     border-radius: 15px !important;
  134.     background: none;
  135.   }
  136.  
  137.   .c-globalProductCard_score {
  138.     display:none;
  139.   }
  140.  
  141.   /* Unnecessary sections*/
  142.   .c-adSkyBox,
  143.   #floor_adhesion,
  144.   .c-aboutSection_fx,
  145.   .c-adDisplay_container,
  146.   .c-aboutSection,
  147.   .c-videoPlaylist,
  148.   #leaderboard-middle-1,
  149.   #leaderboard-middle-2,
  150.   .c-pageFrontDoorTv_row.g-outer-spacing-top-xxlarge.g-outer-spacing-bottom-xxlarge.g-grid-container,
  151.   .c-globalCarousel.g-grid-container.c-globalCarousel_content_inline,
  152.     footer {
  153.     display:none;
  154.   }
  155.  
  156.   /* Section 'Latest News in Games' */
  157.   .c-pageFrontDoorGame_row.g-outer-spacing-top-xxlarge.g-outer-spacing-bottom-xxlarge.g-grid-container {
  158.     display:none;
  159.   }
  160.  
  161.   /* Section 'Latest News in Movies' */
  162.   .c-pageFrontDoorMovie_row.g-outer-spacing-top-xxlarge.g-outer-spacing-bottom-xxlarge.g-grid-container {
  163.     display:none;
  164.   }
  165.   `;
  166.  
  167.  
  168.   // the actual style that will be toggled
  169.   const styleElement = document.createElement('style');
  170.   styleElement.type = 'text/css';
  171.   styleElement.textContent = customCSS;
  172.   document.head.appendChild(styleElement);
  173.  
  174.   // flags that are toggled by the url and the 'v' key
  175.   let styleAllowed = true;
  176.   let styleDisabled = false;
  177.  
  178.   // listen to the 'v' key, unless it's a text input
  179.   document.addEventListener('keyup', (e) => {
  180.  
  181.     const key = String(e.key).toLowerCase();
  182.  
  183.     if (key !== 'v' ||
  184.       e.target.tagName === 'INPUT' ||
  185.       e.target.tagName === 'TEXTAREA'
  186.     ) return;
  187.  
  188.     styleAllowed = !styleAllowed;
  189.  
  190.     handleStyleInjection()
  191.   })
  192.  
  193.   // toggles the style on and off
  194.   function handleStyleInjection() {
  195.  
  196.     const supportedPaths = ['/movie/', '/tv/', '/game/'];
  197.  
  198.     const isMediaPath = supportedPaths.includes(window.location.pathname);
  199.  
  200.     if (isMediaPath && styleAllowed) {
  201.       styleDisabled = false;
  202.     }
  203.     else {
  204.       styleDisabled = true;
  205.     }
  206.  
  207.     styleElement.disabled = styleDisabled;
  208.   }
  209.  
  210.   // Monitor URL changes using MutationObserver (so that we disable the style if we navigate
  211.   // away from /tv). Ideally this script would work on only /tv, but the site is an SPA, so
  212.   // we need to add and remove the style as we navigate through the site.
  213.   const observer = new MutationObserver(() => {
  214.     handleStyleInjection();
  215.   });
  216.  
  217.   observer.observe(document.body, { childList: true, subtree: true });
  218.  
  219.   handleStyleInjection();
  220. })();
  221.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement