F12打开开发者工具,在Console输入以下js代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| (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,.blog-footer-bottom").remove(); $(".p4course_target, .comment-box, .recommend-box, #csdn-toolbar, #tool-box,#dmp_ad_58, .more-toolbox, .article-info-box, .btn-readmore, .pub-footer-new").remove(); $("aside").remove(); $(".tool-box").remove(); $("main").css('display','content'); $("main").css('float','left'); $("#mainBox").width("100%"); document.getElementsByTagName('body')[0].style.zoom=0.8; window.print(); })();
|
或者:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| (function doPrint(){ 'use strict'; var articleBox = $("div.article_content"); articleBox.removeAttr("style"); var head_str = ""; var foot_str = ""; var older = document.body.innerHTML; var title= document.getElementsByClassName('article-title-box')[0].innerHTML; var main_body = document.getElementsByClassName('article_content')[0].innerHTML; document.body.innerHTML = head_str + title + main_body + foot_str; $("#mainBox").width("100%"); document.getElementsByTagName('body')[0].style.zoom=0.8; window.print(); document.body.innerHTML = older; return false; })();
|