您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
try to print to pdf of CSDN!
当前为
// ==UserScript== // @name SurePrintCsdn // @namespace http://surewong.com/SurePrint // @version 0.1 // @description try to print to pdf of CSDN! // @author SureWong // @match https://*.csdn.net/* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // @license AGPL License // ==/UserScript== // 在弹出的打印页面中将页面设置成横,缩放50%,否则显示不全 (function() { 'use strict'; // Your code here... var surePrintBtn = document.createElement('button') surePrintBtn.innerHTML = "准备打印pdf" surePrintBtn.className = "sure-print-pdf" surePrintBtn.onclick = function (e) { document.querySelector("#side")?.remove(); document.querySelector("#comment_title, #comment_list, #comment_bar, #comment_form, .announce, #ad_cen, #ad_bot")?.remove(); document.querySelector(".nav_top_2011, #header, #navigator")?.remove(); document.querySelector(".p4course_target, .comment-box, .recommend-box, #csdn-toolbar, #tool-box")?.remove(); document.querySelector("aside")?.remove(); document.querySelector(".tool-box")?.remove(); document.querySelector(".csdn-side-toolbar")?.remove(); document.querySelector(".more-toolbox")?.remove(); document.querySelector(".template-box")?.remove(); document.querySelector(".bottom-pub-footer")?.remove(); document.querySelector(".pre-numbering")?.remove(); document.querySelector("main").setAttribute('style', 'display: content;'); document.querySelector("main").setAttribute('style', 'float: left;'); window.print(); // document.querySelector("tool-box")?.remove(); } var body = document.body var style = document.createElement('style') style.id = "sure-print-pdf" var css = `.sure-print-pdf{ position: fixed; bottom: 5%; right: 1%; width: 70px; height: 70px; background: #add8e640; color: cornflowerblue; border-radius: 50%; font-size: 10px; z-index: 999; cursor: pointer; font-size: 10px; overflow: hidden; }` if (style.styleSheet) { style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); } body.appendChild(surePrintBtn) body.appendChild(style) })();