免费获取百度文库内容

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/my773962804/article/details/88944826

var pclass = 'reader-word-layer';
var pparts = [];
var pdoc = '';

function getDoc() {
    pdoc = '';
    pparts = document.querySelectorAll('.'+pclass);
    pparts.forEach(function (item) {
        pdoc += item.innerHTML
    });
    pdoc = pdoc.replace(/<.*?>/g,'').replace(/&nbsp;/g,' ');
    var win = window.open();
    win.document.write("<pre>"+pdoc+"</pre>");
}


var style = "-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none; -webkit-box-shadow:  1px 2px 10px #00000022;-moz-box-shadow:  1px 2px 10px #00000022;box-shadow:  1px 2px 10px #00000022;outline:none; padding: 0 30px; border-radius: 15px; z-index: 9999;position: fixed;top: 30px;left: 30px;border: 5px solid #78C941;line-height: 4rem;font-size: 2rem;font-weight: bold;text-align: center;background-color: #fff;";
var href = "data:text/plain;charset=utf-8," + encodeURIComponent(pdoc);
var downA = document.createElement('button');
var downText = document.createTextNode('新标签页中打开文档');
downA.setAttribute('onclick', 'getDoc()');
downA.setAttribute('id', 'downloadA');
downA.setAttribute('style', style);

downA.appendChild(downText);
document.body.appendChild(downA);

猜你喜欢

转载自blog.csdn.net/my773962804/article/details/88944826