habrClear

Clear the Habr layout for easy print.

当前为 2022-06-19 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name           habrClear
// @description    Clear the Habr layout for easy print.
// @description:ru Очищает макет Habr для простой печати.
// @namespace      habr
// @match          https://habr.com/*
// @require        http://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
// @version        1.0
// @author         Nikolay Raspopov
// @license        MIT
// ==/UserScript==

(function() {
    'use strict';
    var $ = window.jQuery;
    $(document).ready( setTimeout( function(){
        $('.tm-header__container').append("<div class='clearIt' style='padding-left: 8px; padding-right: 8px;'><button type='button'> 🧹 </button></div>");
        $('.clearIt').click( function() {
            $('script').remove();
            $('noscript').remove();
            $('iframe').remove();
            $('.tm-header').remove();
            $('.tm-page__sidebar').remove();
            $('.tm-company-profile-card').remove();
            $('.tm-page-progress-bar').remove();
            $('.tm-page__header').remove();
            $('.tm-footer-menu').remove();
            $('.tm-footer').remove();
            $('.tm-base-layout__header').remove();
            $('.tm-article-sticky-panel').remove();
            $('.tm-article-presenter__footer').remove();
            $('.tm-article-presenter__meta').remove();
            $('.persona').remove();
            $('.tm-scroll-top').remove();
            $('.v-portal').remove();
            $('.Vue-Toastification__container').remove();
            $('.vue-portal-target').remove();
            $('.pswp').remove();
            $('html, body, .tm-layout__wrapper, .tm-layout, .tm-layout__container, .tm-page, .tm-page-width, .tm-page__wrapper, .tm-page__main').css({
                'background-color' : 'white',
            });
            $('.article-formatted-body table td').css({
                'border-color' : 'black',
            });
            $('.tm-page, .tm-page-width, .tm-page__main, .tm-article-presenter').css({
                'max-width' : 'none',
                'min-width' : 'none',
                'margin' : 'auto',
                'padding' : 'unset',
            });
            $('.clearIt').remove(); // self-destruct
        });
    }, 2000 ) ); // revive delay
})();