Easy Utaten

Simpler utaten page.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Easy Utaten
// @namespace    https://github.com/Yesterday17/Gadgets
// @version      1.0.0
// @description  Simpler utaten page.
// @author       Yesterday17
// @match        https://utaten.com/*
// @run-at       document-end
// @supportURL   https://github.com/Yesterday17/Gadgets/issues
// ==/UserScript==
(function() {
  const html = document.documentElement;
  const body = document.body;

  function trycatch(cb) {
    try {
      cb();
    } catch {}
  }

  // Remove iframe ads
  document
    .querySelectorAll('iframe')
    .forEach(ifr => (ifr.style.display = 'none'));

  // Remove aside ads
  document
    .querySelectorAll('aside')
    .forEach(asi => (asi.style.display = 'none'));

  // Remove banner ads
  trycatch(() => (document.querySelector('.topBanner').style.display = 'none'));
  trycatch(
    () => (document.querySelector('.footerBanner').style.display = 'none')
  );

  // Enable copy
  const copy = document.createElement('style');
  copy.innerHTML = '* {\n  user-select: auto !important;\n}';
  document.head.append(copy);
  body.onselectstart = () => {
    return true;
  };

  if (document.location.pathname === '/') {
    // Main Page
    trycatch(
      () =>
        (document.querySelector('.topContents__inner').style.display = 'none')
    );
    document.querySelector('#container').style.display = 'none';
    document
      .querySelectorAll('footer')
      .forEach(footer => (footer.style.display = 'none'));

    const top_contents = document.querySelector('.topContents');
    const top_contents_search = top_contents.querySelector(
      '.topContentsSearch'
    );

    html.style.overflow = 'hidden';

    top_contents.style.height = 'calc(100% - 60px)';
    html.style.height = body.style.height = top_contents_search.style.height =
      '100%';

    top_contents_search.style.display = 'flex';
    top_contents_search.style['align-items'] = 'center';
  } else {
    // Remove sidebar
    document.querySelector('#sidebar').style.display = 'none';
    document.querySelector('#contents').style.width = '100%';

    if (document.location.pathname.startsWith('/search/')) {
      // Search Page
      [2, 4].forEach(i => {
        document.querySelector('.contentBox').children[i].style.display =
          'none';
      });
    } else if (document.location.pathname.startsWith('/lyric/')) {
      // Lyric Page
      Array.from(document.querySelector('main').children).forEach((ch, i) => {
        if (i !== 0 && i !== 2) {
          ch.style.display = 'none';
        }
      });
    } else if (document.location.pathname.startsWith('/artist/')) {
      // Artist Page
      Array.from(document.querySelector('main').children).forEach((ch, i) => {
        if (i !== 0 && i !== 3) {
          ch.style.display = 'none';
        }
      });
    }
  }
})();