自定义网站样式

自定义相关网站的样式

目前為 2022-02-18 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         自定义网站样式
// @namespace    http://tampermonkey.net/
// @version      0.1.4
// @description  自定义相关网站的样式
// @author       myaijarvis
// @icon         https://greasyfork.org/packs/media/images/blacklogo16-5421a97c75656cecbe2befcec0778a96.png
// @match        http://localhost:8888/lab/*
// @match        https://*.blog.csdn.net/article/details/*
// @match        https://blog.csdn.net/*/article/details/*
// @match        https://greasyfork.org/zh-CN/scripts/*/versions/new
// @match        https://editor.csdn.net/md/*

// @require      https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    let url=document.URL || '';

    let color_code='#41a144'; // 代码注释的颜色
    if (url.includes('blog.csdn.net')){
        //console.info("setColor");
        // 需要等内容加载 如果还不好用就监听鼠标滚动
        setTimeout(()=>{
            $('.token.comment').css({'color':color_code});
            $('.hljs-comment').css({'color':color_code});
        },1000);
        return;
    }

    //debugger;
    if (url.includes('editor.csdn.net/md')){
        // 需要等内容加载
        setTimeout(()=>{
            //console.info("setColor");
            let $comment=$('.preview .token.comment'); // 预览界面
            $comment.css({'color':color_code});
            $("pre.markdown-highlighting").on("DOMNodeInserted", function (e) {
                //console.log("md change"); // 监听文章内容改变
                //debugger;
                $comment.css({'color':color_code});
                setTimeout(()=>{
                    //console.log($comment);
                    $('.preview .token.comment').css({'color':color_code}); // 这里必须要使用选择器,不能使用$comment,why???
                },500); // 0.5s最合适
            });
        },3000);
        return;
    }

    if (url.includes('localhost:8888/lab')){
        //console.info("setMaxHeight");
        setInterval(()=>{
            $('.jp-OutputArea-output pre').css('max-height','30em');
        },2000);
        return;
    }

    if (url.match('greasyfork\.org\/(.*?)\/scripts\/(.*?)\/versions\/new')){
        //console.info("setMaxHeight");
        let height='500px'; // textarea的高度
        $('#script-version-additional-info-0').css({'height':height});
        $('#script_version_changelog').css({'height':'200px'});
        return;
    }
})();