Luogu--插件

· · 个人记录

一个让洛谷更加安静的插件。

<!--more-->

插件目前是使用纯 CSS 的,因此可以用 Stylish 加载。当然也可以用 JavaScript 加载,因此也附了给 TamperMonkey 使用的 JavaScript 代码(不一定能够及时更新)。

CSS 代码

推荐使用 Stylish 加载。适配开启“学术模式”的洛谷,配置 Extend-Luogu 插件。

/* ================================ 回退头像 dropdown ===================================== */

span.wrapper.hover > div.dropdown > div.center > div:not(.ops) { display: none }
div#exlg-dash { display: none }
span.wrapper.hover > div.dropdown > div.center > footer { padding-top: 0; padding-bottom: 0 }
.color-none.exlg-dash-options:nth-child(7) { display: none }
.ops > a.color-none.exlg-dash-options {
    display: inline-block;
    width: 7em;
    margin-top: 0.4em;
    margin-bottom: 0.4em;
    padding: 0px
}
.ops > a.color-none.exlg-dash-options > div.link-title { display: inline-block }
.ops > a.color-none.exlg-dash-options:after { display: none }
footer[data-v-78704ac9] { font-size: 0.8em }
.ops > a.color-none.exlg-dash-options > .link-title > svg {
    margin-right: inherit;
    width: inherit
}
.ops[data-v-78704ac9] { padding: 0.5em 0.2em }
.center[data-v-78704ac9] { width: 238px }


/* ======================================== 主页大改 ====================================== */

div#exlg-board > h2 { display: none } /* exlg logo */
div#exlg-board ~ div.lg-article:nth-child(2) { display: none } /* 本站公告 */
div#exlg-board ~ div.lg-article:nth-child(4) { display: none!important } /* 友情链接 */
div#exlg-board ~ div.lg-article:nth-child(3) > h2 ~ h2 { display: none } /* 智能推荐 */
div#exlg-board ~ div.lg-article:nth-child(3) > h2 ~ h2 ~ div { display: none } /* 智能推荐内容 */
div.am-u-lg-9.am-u-md-8.lg-index-benben.lg-right > div.lg-article:first-child { display: none } /* 近期比赛 */
div.am-u-lg-3.am-u-md-4.lg-right { display: flex; flex-direction: column-reverse } /* 前置任务计划 */
#exlg-board { display: none } /* 隐藏查找用户、犇犇排行榜所在的框 */
#bb-rnklst-h2 { display: none } /* 隐藏犇犇排行榜 */
.lg-index-benben > .lg-article:nth-child(2) { display: none } /* 学术模式下关闭讨论框 */
.am-u-md-3 .lg-index-stat { display: none } /* 问题跳转 */
.am-u-md-9 .lg-index-stat { display: none } /* 通过统计 */
.exlg-rand-settings#exlg-dash-0 { display: none } /* “ex 设置” */
.am-u-md-3 .lg-index-stat button[name="gotorandom"] {display: none } /* 随机跳转的按钮 */
.am-u-md-3 .lg-index-stat button[name="gotorandomex"] {display: none } /* 随机跳转的 exlg 按钮 */
.am-u-md-12 { display: none } /* slider 与运势、打卡 */
#exlg-board + * + .lg-article > div:not(.tasklist-item) { display: none } /* 隐藏“隐藏已 AC” */

/* 隐藏首页 slide */
div.am-g > div.am-u-md-12 div.am-u-md-8 { display: none }
div.am-g > div.am-u-md-12 > div.lg-article > div.am-g { display: flex; justify-content: center }


/* ======================================== 关闭功能 ======================================= */

span.exlg-badge { display: none } /* exlg 的 badge */
section.side > div { display: none } /* 侧栏广告 */
.footer .qr-img { display: none } /* footer 的二维码 */
.footer .logo-img { display: none } /* footer 的 logo */
.footer .slogan { display: none } /* footer 的 slogan */
button[name="save-discuss"] ~ *, button[name="save-discuss"] { display: none } /* 隐藏 exlg 的“保存讨论”和“讨论备份” */
.solution-article { display: none } /* 隐藏题解 */

/* 表情输入 */
.exlg-emo { display: none }
.mp-editor-ground.exlg-ext.exlg-show-emo.exlg-show-emo-short { top: 40px!important }

/* 隐藏等级钩、管理员和棕名的 badge */
.sb_amazeui { display: none } 
.exlg-badge-username + .am-badge, .exlg-badge-username + .sb_amazeui + .am-badge { display: none }
section.side .info-rows a[href="/discuss/show/142324"] { display: none }
.creator a[href="/discuss/show/142324"], .user-name a[href="/discuss/show/142324"], .user a[href="/discuss/show/142324"],
.inner-card .right-box a[href="/discuss/show/142324"], .follow-left a[href="/discuss/show/142324"] { display: none }
section.side .info-rows .lfe-caption:not(.tag) { display: none }
.feed-username .am-badge { display: none }
.lg-index-contest .lg-small { font-size: 0 }
.lg-index-contest .lg-small a, .lg-index-contest .lg-small + .lg-small, .lg-index-contest .lg-small + .lg-small * { font-size: 10px }

JavaScript 代码

除了适用 TamperMonkey 以外,和 CSS 代码的适用提示一样。

// ==UserScript==
// @name         Luogu--
// @version      0.1
// @description  Less luogu features!
// @author       Kuriyama Mirai
// @match        https://www.luogu.com.cn/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=luogu.com.cn
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
  let style = document.createElement('style');
  style.innerHTML = '/* ================================ 回退头像 dropdown ===================================== */\
  \
  span.wrapper.hover > div.dropdown > div.center > div:not(.ops) { display: none }\
  div#exlg-dash { display: none }\
  span.wrapper.hover > div.dropdown > div.center > footer { padding-top: 0; padding-bottom: 0 }\
  .color-none.exlg-dash-options:nth-child(7) { display: none }\
  .ops > a.color-none.exlg-dash-options {\
    display: inline-block;\
    width: 7em;\
    margin-top: 0.4em;\
    margin-bottom: 0.4em;\
    padding: 0px\
  }\
  .ops > a.color-none.exlg-dash-options > div.link-title { display: inline-block }\
  .ops > a.color-none.exlg-dash-options:after { display: none }\
  footer[data-v-78704ac9] { font-size: 0.8em }\
  .ops > a.color-none.exlg-dash-options > .link-title > svg {\
    margin-right: inherit;\
    width: inherit\
  }\
  .ops[data-v-78704ac9] { padding: 0.5em 0.2em }\
  .center[data-v-78704ac9] { width: 238px }\
  \
  \
  /* ======================================== 主页大改 ====================================== */\
  \
  div#exlg-board > h2 { display: none } /* exlg logo */\
  div#exlg-board ~ div.lg-article:nth-child(2) { display: none } /* 本站公告 */\
  div#exlg-board ~ div.lg-article:nth-child(4) { display: none!important } /* 友情链接 */\
  div#exlg-board ~ div.lg-article:nth-child(3) > h2 ~ h2 { display: none } /* 智能推荐 */\
  div#exlg-board ~ div.lg-article:nth-child(3) > h2 ~ h2 ~ div { display: none } /* 智能推荐内容 */\
  div.am-u-lg-9.am-u-md-8.lg-index-benben.lg-right > div.lg-article:first-child { display: none } /* 近期比赛 */\
  div.am-u-lg-3.am-u-md-4.lg-right { display: flex; flex-direction: column-reverse } /* 前置任务计划 */\
  #exlg-board { display: none } /* 隐藏查找用户、犇犇排行榜所在的框 */\
  #bb-rnklst-h2 { display: none } /* 隐藏犇犇排行榜 */\
  .lg-index-benben > .lg-article:nth-child(2) { display: none } /* 学术模式下关闭讨论框 */\
  .am-u-md-3 .lg-index-stat { display: none } /* 问题跳转 */\
  .am-u-md-9 .lg-index-stat { display: none } /* 通过统计 */\
  .exlg-rand-settings#exlg-dash-0 { display: none } /* “ex 设置” */\
  .am-u-md-3 .lg-index-stat button[name="gotorandom"] {display: none } /* 随机跳转的按钮 */\
  .am-u-md-3 .lg-index-stat button[name="gotorandomex"] {display: none } /* 随机跳转的 exlg 按钮 */\
  .am-u-md-12 { display: none } /* slider 与运势、打卡 */\
  #exlg-board + * + .lg-article > div:not(.tasklist-item) { display: none } /* 隐藏“隐藏已 AC” */\
  \
  /* 隐藏首页 slide */\
  div.am-g > div.am-u-md-12 div.am-u-md-8 { display: none }\
  div.am-g > div.am-u-md-12 > div.lg-article > div.am-g { display: flex; justify-content: center }\
  \
  \
  /* ======================================== 关闭功能 ======================================= */\
  \
  span.exlg-badge { display: none } /* exlg 的 badge */\
  section.side > div { display: none } /* 侧栏广告 */\
  .footer .qr-img { display: none } /* footer 的二维码 */\
  .footer .logo-img { display: none } /* footer 的 logo */\
  .footer .slogan { display: none } /* footer 的 slogan */\
  button[name="save-discuss"] ~ *, button[name="save-discuss"] { display: none } /* 隐藏 exlg 的“保存讨论”和“讨论备份” */\
  .solution-article { display: none } /* 隐藏题解 */\
  \
  /* 表情输入 */\
  .exlg-emo { display: none }\
  .mp-editor-ground.exlg-ext.exlg-show-emo.exlg-show-emo-short { top: 40px!important }\
  \
  /* 隐藏等级钩、管理员和棕名的 badge */\
  .sb_amazeui { display: none } \
  .exlg-badge-username + .am-badge, .exlg-badge-username + .sb_amazeui + .am-badge { display: none }\
  section.side .info-rows a[href="/discuss/show/142324"] { display: none }\
  .creator a[href="/discuss/show/142324"], .user-name a[href="/discuss/show/142324"], .user a[href="/discuss/show/142324"],\
  .inner-card .right-box a[href="/discuss/show/142324"], .follow-left a[href="/discuss/show/142324"] { display: none }\
  section.side .info-rows .lfe-caption:not(.tag) { display: none }\
  .feed-username .am-badge { display: none }\
  .lg-index-contest .lg-small { font-size: 0 }\
  .lg-index-contest .lg-small a, .lg-index-contest .lg-small + .lg-small, .lg-index-contest .lg-small + .lg-small * { font-size: 10px }';
  let ref = document.querySelector('body');
  ref.parentNode.insertBefore(style, ref);
})();

已知 bug