clean CSDN blog

还你一个干净的阅读体验

Stan na 07-08-2017. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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