Easy Utaten

Simpler utaten page.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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';
        }
      });
    }
  }
})();