编程猫主页优化

对于编程猫主页的部分优化

目前为 2022-09-25 提交的版本。查看 最新版本

// ==UserScript==
// @name         编程猫主页优化
// @namespace    http://tampermonkey.net/
// @version      1.2.1.13
// @description  对于编程猫主页的部分优化
// @author       小鱼yuzifu
// @match        https://shequ.codemao.cn/*
// @icon         https://shequ.codemao.cn/favicon.ico
// @grant        GM_xmlhttpRequest
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';
    GM_xmlhttpRequest({
        method: "get",
        url: "https://shequ.codemao.cn/",
        data: document.cookie,
        binary: true,
        async onload({ response }) {
            $("li[data-watch_event='下载APP-入口tab']").after(`<li class="event_target data_report c-navigator--item" data-watch_event="设置-入口tab" data-extra_word_one="点击" data-data_report_btn_name="设置-入口tab"><a href="#">设置</a></li>`);
            document.documentElement.style.setProperty('--main-color', localStorage.getItem('main-color') || '#fec433');
            document.documentElement.style.setProperty('--second-color', localStorage.getItem('second-color') || '#f6b206');
            document.documentElement.style.setProperty('--person-color', localStorage.getItem('person-color') || '#000');
            $("head").after(`
     <style>
    .r-community-r-detail-c-report_posts--option:hover,
    .mce-foot .mce-first.mce-primary:hover,
    .r-community-c-forum_editor--save:hover,
    .r-community-r-detail--send_btn:hover,
    .r-community-r-detail--add_reply:hover,
    .r-community-r-detail-c-report_comment--option:hover,
    .r-community-r-detail-c-comment_reply--reply_container .r-community-r-detail-c-comment_reply--reply_bottom .r-community-r-detail-c-comment_reply--reply_sender .r-community-r-detail-c-comment_reply--reply_send a:hover,
    .r-community-c-forum_sender--option:hover,
    .r-community--send_btn:hover,
    .r-user-c-banner--btn:hover,
    .r-work-c-report_work--option:hover,
    .r-work-c-comment_area--comment_btn:hover,
    .c-dialog-c-confirm_box_center--btns .c-dialog-c-confirm_box_center--confirm:hover,
    .r-work-c-author_info--focus_btn.r-work-c-author_info--not_focus:hover,
    .r-setting--main_area .r-setting--btn_save:hover,
    .c-navigator--header-content .c-navigator--nav_wrap .c-navigator--selected,
    .c-navigator--header-content .c-navigator--nav_wrap .c-navigator--item:hover,
    .c-navigator--header-content .c-navigator--user_wrap .c-navigator--avatar_wrap:hover,
    .c-navigator--header-content .c-navigator--user_wrap .c-navigator--message_wrap:hover{
        background: var(--second-color)!important;
    }
    .r-community-r-detail-c-report_posts--option,
    .mce-foot .mce-first.mce-primary,
    .r-community-c-forum_editor--save,
    .r-community-r-detail--send_btn,
    .r-community-r-detail--add_reply,
    .r-community-r-detail-c-report_comment--container .r-community-r-detail-c-report_comment--label_group .r-community-r-detail-c-report_comment--item_point i,
    .r-community-r-detail-c-report_comment--option,
    .r-community-r-detail-c-comment_reply--reply_container .r-community-r-detail-c-comment_reply--reply_bottom .r-community-r-detail-c-comment_reply--reply_sender .r-community-r-detail-c-comment_reply--reply_send a,
    .r-community--forum_filter .r-community--filter_tab.r-community--active span,
    .r-community-c-forum_sender--option,
    .r-community--send_btn,
    .r-discover-c-tagList--sort_cont .r-discover-c-tagList--sort_item.r-discover-c-tagList--select,
    .r-user-c-banner--btn,
    .r-message--container .r-message--nav_item.r-message--cur_nav:after,
    .c-pagination--activePage,
    .r-work-c-report_work--option,
    .r-work-c-comment_area--comment_btn,
    .c-dialog-c-confirm_box_center--btns .c-dialog-c-confirm_box_center--confirm,
    .r-work-c-author_info--focus_btn.r-work-c-author_info--not_focus,
    .r-setting--main_area .r-setting--btn_save,
    .c-navigator--navigator,
    .c-navigator--header-content{
        background: var(--main-color)!important;
    }
    .mce-btn:hover,
    .r-community-r-detail--roules_btn:hover,
    .r-community-r-detail-c-comment_reply--reply_btn:hover,
    .r-community-r-detail-c-comment_item--content_container .r-community-r-detail-c-comment_item--content_bottom .r-community-r-detail-c-comment_item--content_praise.r-community-r-detail-c-comment_item--active i,
    .r-community-r-detail-c-comment_item--active,
    .r-community--forum_filter .r-community--filter_tab.r-community--active,
    .r-community--forum_filter .r-community--filter_tab:hover,
    .r-community--roules_btn:hover,
    .r-discover-c-workcard--work_item .r-discover-c-workcard--author a:hover,
    .r-discover-c-tagList--sort_cont .r-discover-c-tagList--sort_item:hover,
    .r-discover--header .r-discover--switch-box li:hover,
    .r-discover--active,
    .r-discover-c-banner--banner_cont .r-discover-c-banner--item p:hover,
    .r-home-c-section_header--right_text,
    .r-message-c-comments--work_name,
    .r-message-c-system_message--work_name,
    .r-message--nav_item:hover,
    .r-message--load_more:hover,
    .r-message-c-buy--work_name,
    .r-message--container .r-message--nav_item.r-message--cur_nav, .r-message--container .r-message--nav_item.r-message--cur_nav span,
    .r-work-c-work_info--work_tool,
    .r-work-c-comment_area-c-comment_item--active,
    .r-work-c-comment_area-c-comment_item--active i{
        color: var(--main-color)!important;
    }
    .r-community-r-detail-c-report_posts--editor:focus,
    .mce-foot .mce-btn:hover,
    .r-community-r-detail-c-report_comment--editor:focus,
    .r-community-r-detail-c-report_comment--container .r-community-r-detail-c-report_comment--label_group .r-community-r-detail-c-report_comment--item_point:hover,
    .r-community-r-detail-c-report_comment--container .r-community-r-detail-c-report_comment--label_group .r-community-r-detail-c-report_comment--item_point.r-community-r-detail-c-report_comment--select,
    .r-community-r-detail-c-comment_reply--reply_editor:focus,
    .r-community-r-detail-c-comment_reply--reply_btn:hover,
    .r-community--small:focus,
    .r-community-c-forum_sender--title_input:focus,
    .r-discover--header .r-discover--search-box input:focus,
    .r-discover-c-tagList--sort_cont .r-discover-c-tagList--sort_item.r-discover-c-tagList--select,
    .r-discover-c-tagList--sort_cont .r-discover-c-tagList--sort_item:hover,
    .r-message--load_more:hover,
    .c-pagination--activePage,
    .c-dialog-c-confirm_box_center--confirm{
        border-color:var(--main-color)!important;
    }
    .r-discover--icon{
        right: -1000px!important;
        filter: drop-shadow(-1012px 0px 0px var(--main-color));
    }
    .r-community--search_form .r-community--search_btn{
        right: -1000px!important;
    }
    .r-community--icon_search{
        filter: drop-shadow(-1000px 0px 0px var(--main-color));
    }
     </style>`);

            $("li[data-watch_event='设置-入口tab']").click(function () {
                $(".c-dialog--dialog_cover").after(`
                <div id="yzf-settings" style="text-align: left;background:white;border-radius:5px;position: absolute;width:500px;height:50vh;top:0;left:0;z-index: 100;margin: 25vh calc(50vw - 250px);padding: 50px;">
                    <span>首要主题色</span> <input onchange="document.documentElement.style.setProperty('--main-color', this.value);localStorage.setItem('main-color', this.value);" id="main-color" type="color" value="#ff0000"></input>
                    <br>
                    <br>
                    <span>次要主题色</span> <input onchange="document.documentElement.style.setProperty('--second-color', this.value);localStorage.setItem('second-color', this.value);" id="second-color" type="color" value="#ff0000"></input>
                    <br>
                    <br>
                    <span>个人主页背景色</span> <input onchange="document.documentElement.style.setProperty('--person-color', this.value);localStorage.setItem('person-color', this.value);" id="person-color" type="color" value="#ff0000"></input>
                    <br>
                    <br>
                    <button id="yzf-close" style="width:100%">点我关闭</button>
                </div>
                `);
                $("#yzf-close").click(() => { $('.c-dialog--dialog_wrap').removeClass('c-dialog--visiable c-dialog--show') })
                $("#main-color").val(localStorage.getItem('main-color') || '#fec433')
                $("#second-color").val(localStorage.getItem('second-color') || '#f6b206')
                $("#person-color").val(localStorage.getItem('person-color') || '#000')
                $(".c-dialog--dialog_wrap").addClass('c-dialog--visiable c-dialog--show')
            });
        }
    })
    $("head").after(`
     <style>
     #yzf-settings span{
         font-size:20px;
         float: left;
     }
     #yzf-settings input[type='color']{
         width:30px;
         height:30px;
         font-size:20px;
         float: right;
         text-align: center;
     }
     .c-badge--icon,
     .r-home-c-box3_recommend--recommend_work,
     .c-side_nav--slide_nav,
     .r-home-c-novel_area--novel_area,
     .r-home-c-code_tv--novel_area,
     li[data-watch_event='课程-入口tab'],
     li[data-watch_event='素材-入口tab'],
     li[data-watch_event='下载APP-入口tab'],
     li[data-watch_event='更多-入口tab'],
     .c-footer--footer_wrap
     {
     display:none !important
     }
     .r-user-c-banner--banner .r-user-c-banner--background{
     background-image: url();
     background-color: var(--person-color);
     }
     body{
     overflow-x: hidden;
     }
     *::-webkit-scrollbar {
            width: 5px;
            height: 5px;
        }
    *::-webkit-scrollbar-thumb {
        border-radius: 10px;
        box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
        background-color:  var(--main-color);
    }
    *::-webkit-scrollbar-thumb:hover {
        background-color:  var(--second-color);
    }
     </style>`);
})();