// ==UserScript== // @name SaveToPDF // @namespace https://ztjun.fun // @version 1.1 // @description 52pojie、CSDN、简书、Myitmx、博客园文章一键保存为PDF // @author null119 // @match https://www.52pojie.cn/* // @match https://blog.csdn.net/* // @match https://www.myitmx.com/* // @match https://www.jianshu.com/* // @match https://www.cnblogs.com/* // @icon https://https://ztjun.fun/wp/wp-content/uploads/img/202202140807071.png // @grant none // @downloadURL none // ==/UserScript== (function() { "use strict"; var host,url,wtype,imgurl imgurl='https://ztjun.fun/wp/wp-content/uploads/img/202202150530227.png'; window.onload=function(){ var up,nxg1,newa,nimg,ndiv,allshow; url=window.location.href; up="//.*?\\.(.*?)\\." host=url.match(up)[1]; if(host==="52pojie"){ wtype=0 } if(host==="csdn"){ wtype=1 } if(host==="myitmx"){ wtype=2 } if(host==="jianshu"){ wtype=3 } if(host==="cnblogs"){ wtype=4 } switch(wtype) { case 0: nxg1 = document.getElementById("newspecial"); if (nxg1) { nimg=document.createElement("img"); nimg.src="https://ztjun.fun/wp/wp-content/uploads/img/202202140612986.png"; newa = document.createElement("a"); newa.id="HtmToPDF"; newa.href="javascript:SaveToPDF();"; newa.title="收藏"; newa.appendChild(nimg); nxg1.parentNode.insertBefore(newa,nxg1.nextSibling); var doc=document.getElementsByClassName("zoom") for(var i=0;i0){ for (var j = 0; j/g,''); } const newWin = window.open(""); newWin.document.body.innerHTML = ''+title+'

'+title+"

"+prnhtml+""; newWin.document.close(); newWin.focus(); setTimeout(() => { newWin.print(); newWin.close(); }, 300); }; })();