如何打印排版整洁的CSDN文章? 教你PDF一键导出

使用方法:在Chrome浏览器中,按“Ctrl+Shift+I”进入开发者工具,将以下代码复制到 console,回车即可一键打印。

1、自动“展开阅读全文”
2、删除顶栏、侧栏、相关文章展示、浏览信息、广告、点赞等多余信息。真正的全清爽模式。
3、自动输出打印预览

(function(){
    
    
    'use strict';
    var articleBox = $("div.article_content");
    articleBox.removeAttr("style");
    $("#btn-readmore").parent().remove();
    $("#side").remove();
    $("#comment_title, #comment_list, #comment_bar, #comment_form, .announce, #ad_cen, #ad_bot").remove();
    $(".nav_top_2011, #header, #navigator").remove();
    $(".csdn-side-toolbar,.template-box,.reward-user-box").remove();
    $(".p4course_target, .comment-box, .recommend-box, #csdn-toolbar, #tool-box,#dmp_ad_58, .more-toolbox, .article-info-box, .btn-readmore").remove();
    $("aside").remove();
    $(".tool-box").remove();
    $("main").css('display','content');
    $("main").css('float','left');
    $("#mainBox").css('width','100%');
    $(".main_father.clearfix.d-flex.justify-content-center").css("width","100%");
    window.print();
})();

操作如下:
在这里插入图片描述
效果如下:
在这里插入图片描述

参考资料

gitee
https://www.cnblogs.com/jiangkejie/p/13221446.html

猜你喜欢

转载自blog.csdn.net/OuDiShenmiss/article/details/109261672