vbird-linux-prettify

美化《鸟哥的Linux私房菜》网站:用等宽字体显示所有代码;隐藏部分页面元素;

目前为 2017-07-09 提交的版本。查看 最新版本

// ==UserScript==
// @name         vbird-linux-prettify
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  美化《鸟哥的Linux私房菜》网站:用等宽字体显示所有代码;隐藏部分页面元素;
// @author       Yang Li
// @match        http://linux.vbird.org/*
// @require      https://code.jquery.com/jquery-3.2.1.slim.min.js
// @grant        none
// ==/UserScript==

$(document).ready(function(){
    // v0.1
    //
    //    var $myfont='font: 10pt "Anonymous Pro", Courier, monospace !important; line-height: 1.4 !important;';
    //    $('table.term td *').attr('style', $myfont);
    
    // v0.2
    //   1. 通过添加class来添加新的css规则,避免覆盖原有的font以外的规则(比如下划线)
    //
    $('<style> .monospaced_code {font: 14px "Anonymous Pro", Consolas, monospace !important; line-height: 1.4 !important;} </style>').appendTo('head');
    $('table.term td *').addClass('monospaced_code');
    
    // v0.3
    //   0. 脚本更名:从 vbird-linux-monospaced-code 改为 vbird-linux-prettify
    //   1. 删除顶部和底部banner、左侧前一页按钮、右侧后一页按钮、左上方导航窗口、页面修订历史
    //   2. 浏览器窗口宽度改变时,正文区域随之调整
    //   3. 把正文区域放置在页面正中
    //   4. 调整最底部三个导航按钮的位置
    //
    $('.toparea, .bottomarea, .leftarea, .rightarea, .nav, .mainarea > div:nth-last-child(3)').remove();
    $('.tablearea').css({'min-width':'400px','max-width':'900px','width':'90%'});
    $('.mainarea').css({'width':'100%','position':'static','float':'none'});
    $('.mainarea > div:last-child').css('margin-top','20px');
    
    // v0.4
    //   1. 让代码区域根据正文区域调整宽度
    //   2. 浏览器窗口变窄时,图片宽度相应缩小;统一设置图片边框
    //   3. 例题区域根据浏览器窗口宽度调整
    //   4. 例题代码使用紫色等宽字体
    //   5. 强调语句(蓝色)使用橙色等宽字体
    //   6. 重点回顾区域偶数行使用浅蓝色字体,避免视觉疲劳
    //   7. 增加文末习题答案可见度
    //
    $('table.term').css({'display':'block','overflow':'auto','width':'90%'});
    $('pre').css('width','100%');
    $('div > img').css({'max-width':'90%','border':'2px dotted #5a3'});
    $('table.exam').css({'display':'block','overflow':'auto'});
    $('table.exam blockquote').css({'font':'14px monospace','color':'#c0c'});
    $('.text_import2').css({'font':'16px monospace','color':'#e60'});
    $('ul.text_import2 > li:nth-child(even)').css('color','#06e');
    $('.blockex').css({'color':'#eee','font':'14px monospace'});
});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址