clean CSDN blog

还你一个干净的阅读体验

Verze ze dne 19. 09. 2017. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         clean CSDN blog
// @namespace    http://tampermonkey.net/
// @version      0.1.3
// @description  还你一个干净的阅读体验
// @author       Lynxz
// @match        http://blog.csdn.net/*/article/details/*
// @grant        none
// ==/UserScript==
// CSDN文章清除博客文章侧边栏和广告元素
// CSDN已自带jquery了,不需要添加此依赖
(function() {
    'use strict';
    let bodyWidth = $(document.body).width();
    var oriWidth = $('#main').width() || bodyWidth;
    // 删除blog页面左侧个人资料等侧边栏
    $('#side').remove();
    // 移除blog内容区域右侧上层互动的二维码和快速回复,我要收藏等元素
    $('.csdn-tracking-statistics:not(.article_content)').remove();
    $('.left_fixed').remove();
    $('aside').remove();
    $('#layerd').remove();
    // 设置blog内容区域width 100%,填满移除侧边栏后的区域
    $('#main').css('padding-left',0);
    $('#main').css('width','100%');
    $('#main .main').css('padding-left','0px');
    $('#main .main').css('margin-left','0px');
    $('#article_content').removeAttr('style');
    let curWidth = $('#main').width() || $('#article_content').width();
    // 设置文章内容区域的宽度,默认880px,避免阅读时眼球左右转动幅度过大,自行按需调整吧
    let w = $('#article_details').width() || oriWidth;
    let defaultWidth = 880;
    let margin = (w - defaultWidth) / 2 ;
    console.log("oriWidth = " + oriWidth + " curWidth = " + curWidth + "  w = " + w + " margin = " + margin);
    if(margin > 10){
        $('.container').width(defaultWidth);
        $('main').width(defaultWidth);
        $('#article_details').width(defaultWidth);
        $('#article_details').css('margin-left', margin +'px');
    }
})();