CSDN优化

CSDN阅读优化

2018-11-29 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name CSDN优化
// @description CSDN阅读优化 
// @namespace Violentmonkey Scripts
// @match *://*.blog.csdn.net/*/article/details/*
// @grant none
// @version 1.0
// ==/UserScript==
function hide(dom) {
  if (!dom) {
    return
  }
  if (dom instanceof NodeList) {
    dom.forEach(function(item, index) {
      item.style.display = 'none'
    })
  }
  if (dom instanceof Node) {
    dom.style.display = 'none'
  }
}

// 去除查看更多登陆限制
hide(document.querySelector('.hide-article-box'))
document.querySelector('#article_content').style.height = 'auto'
document.querySelector('#article_content').style.overflow = 'auto'

// 底栏
hide(document.querySelector('.pulllog-box'))

// 去除广告
hide(document.querySelectorAll('.recommend-ad-box'))
hide(document.querySelector('#adContent'))
hide(document.querySelector('._360_interactive'))
hide(document.querySelector('.fourth_column'))
document.querySelectorAll('main>*').forEach(function(item, index) {
  var idStr = item.getAttribute('id') || ''
  if (idStr.indexOf('_ad') != -1) {
    hide(item)
  }
})
document.querySelectorAll('aside>*').forEach(function(item, index) {
  var classStr = item.className || ''
  var idStr = item.getAttribute('id') || ''
  if (classStr.indexOf('csdn-tracking-statistics') != -1) {
    hide(item)
  } else if (idStr == 'asideFooter') {
    if (item.children.length == 2) {
      hide(item.children[0])
    }
  }
})