张鑫旭博客 特别清爽版

去除张鑫旭博客上面各种广告, 并且将正文宽度调整到最适合观看的角度, 让你全身心的投入到阅读学习当中

当前为 2018-08-01 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         张鑫旭博客 特别清爽版
// @namespace    https://greasyfork.org/zh-CN/scripts/370790
// @version      0.2
// @description  去除张鑫旭博客上面各种广告, 并且将正文宽度调整到最适合观看的角度, 让你全身心的投入到阅读学习当中
// @author       zhenhappy
// @match        https://www.zhangxinxu.com/**
// ==/UserScript==

const $ = document.querySelector.bind(document);
const $$ = document.querySelectorAll.bind(document);

(function() {
    'use strict';

    const removeList = [
        '#sidebar',
        '.da_title',
        '.da_col2',
        '.link',
        '.ins_txt',
        '#daITxz2',
        '.hd_remind',
        '.description'
    ]

    removeList.forEach(remove);

    if (document.getElementById('content')) document.getElementById('content').style.marginLeft = "0";
    if (document.getElementById('content')) document.getElementById('content').style.marginRight = "0";
    if (document.getElementById('content')) document.getElementById('content').style.paddingLeft = "0";
    if (document.getElementById('content')) document.getElementById('content').style.paddingRight = "0";
    if (document.getElementById('respond')) document.getElementById('respond').style.paddingLeft = "0";
    if (document.getElementById('respond')) document.getElementById('respond').style.paddingRight = "0";
    if (document.querySelector('.commentlist')) document.querySelector('.commentlist').style.paddingLeft = "0";
    if (document.querySelector('.commentlist')) document.querySelector('.commentlist').style.paddingRight = "0";

    if (document.querySelector('#content > .post')) document.querySelector('#content > .post').style.marginLeft = "auto";
    if (document.querySelector('#content > .post')) document.querySelector('#content > .post').style.marginRight = "auto";
    if (document.getElementById('respond')) document.getElementById('respond').style.marginLeft = "auto";
    if (document.getElementById('respond')) document.getElementById('respond').style.marginRight = "auto";
    if (document.querySelector('.commentlist')) document.querySelector('.commentlist').style.marginLeft = "auto";
    if (document.querySelector('.commentlist')) document.querySelector('.commentlist').style.marginRight = "auto";

    if (document.querySelector('#content > .post')) document.querySelector('#content > .post').style.width = "1440px";
    if (document.querySelector('#content > .post')) document.querySelector('#content > .post').style.maxWidth = "90%";
    if (document.getElementById('respond')) document.getElementById('respond').style.width = "1440px";
    if (document.getElementById('respond')) document.getElementById('respond').style.maxWidth = "90%";
    if (document.querySelector('.commentlist')) document.querySelector('.commentlist').style.width = "1440px";
    if (document.querySelector('.commentlist')) document.querySelector('.commentlist').style.maxWidth = "90%";

})();

function remove(el) {
    if (typeof el === "string") remove([...$$(el)]);
    else if (el instanceof HTMLElement) el.parentNode.removeChild(el);
    else if (el instanceof NodeList) remove([...el]);
    else if (el instanceof Array) el.forEach(remove);
}