在您安装前,Greasy Fork 希望您知道此脚本声明其包含了一些负面功能。这些功能也许会使脚本作者获利,而不能给您带来任何直接的金钱收益。
您只有在参与某些事后才能使用脚本的全部功能,如加入某群组、订阅某频道或在某页点赞等。
脚本作者的说明:
为防止接口被盗!该脚本需要输入验证码之后才能使用完整功能,感谢理解
Greasy Fork is available in English.
【本脚本功能】保持源文件排版导出 PDF 文件,解除继续阅读限制,净化弹窗、广告,开启文库本地 VIP,淘宝、天猫、京东商品优惠券查询
当前为
// ==UserScript==
// @name 百度文库下载器,VIP文档免VIP下载 | 全文阅读| 开启右键复制
// @version 1.7.5
// @description 【本脚本功能】保持源文件排版导出 PDF 文件,解除继续阅读限制,净化弹窗、广告,开启文库本地 VIP,淘宝、天猫、京东商品优惠券查询
// @author zhihu
// @antifeature membership 为防止接口被盗!该脚本需要输入验证码之后才能使用完整功能,感谢理解
// @license End-User License Agreement
// @match *://wenku.baidu.com/view*
// @match *://wk.baidu.com/view*
// @match *://wenku.baidu.com/tfview*
// @match *://wk.baidu.com/tfview*
// @icon https://www.baidu.com/favicon.ico
// @grant GM_getValue
// @grant GM.getValue
// @grant GM_setValue
// @grant GM.setValue
// @connect wenku.baidu.com
// @connect bdimg.com
// @connect tool.wezhicms.com
// @connect zhihuweb.com
// @grant unsafeWindow
// @grant GM.xmlHttpRequest
// @grant GM_xmlhttpRequest
// @run-at document-start
// @namespace http://zhihupe.com/
// ==/UserScript==
(function () {
'use strict';
function getvip() {
// 注册个 MutationObserver,根治各种垃圾弹窗
let count = 0;
const blackListSelector = [
'.vip-pay-pop-v2-wrap',
'.reader-pop-manager-view-containter',
'.fc-ad-contain',
'.shops-hot',
'.video-rec-wrap',
'.pay-doc-marquee',
'.card-vip',
'.vip-privilege-card-wrap',
'.doc-price-voucher-wrap',
'.vip-activity-wrap-new',
'.creader-root .hx-warp',
'.hx-recom-wrapper',
'.hx-bottom-wrapper',
'.hx-right-wrapper.sider-edge'
]
const killTarget = (item) => {
if (item.nodeType !== Node.ELEMENT_NODE) return false;
let el = item;
if (blackListSelector.some(i => (item.matches(i) || (el = item.querySelector(i)))))
el?.remove(), count++;
return true
}
const observer = new MutationObserver((mutationsList) => {
for (let mutation of mutationsList) {
killTarget(mutation.target)
for (const item of mutation.addedNodes) {
killTarget(item)
}
}
});
observer.observe(document, { childList: true, subtree: true });
window.addEventListener("load", () => {
console.log(`[-] 文库净化:共清理掉 ${count} 个弹窗~`);
});
let pageData, pureViewPageData;
let readerdata = GM_getValue('readerinfo');
Object.defineProperty(unsafeWindow, 'pageData', {
set: v => pageData = v,
get() {
if (!pageData) return pageData;
// 启用 VIP
if ('vipInfo' in pageData) {
pageData.vipInfo.global_svip_status = 1;
pageData.vipInfo.global_vip_status = 1;
pageData.vipInfo.isVip = 1;
pageData.vipInfo.isWenkuVip = true;
}
if ('readerInfo' in pageData && pageData?.readerInfo?.htmlUrls?.json) {
if (readerdata) {
pageData.readerInfo = readerdata;
} else {
pageData.readerInfo.showPage = pageData.readerInfo.htmlUrls.json.length;
}
}
if ('appUniv' in pageData) {
// 取消百度文库对谷歌、搜狗浏览器 referrer 的屏蔽
pageData.appUniv.blackBrowser = [];
// 隐藏 APP 下载按钮
pageData.viewBiz.docInfo.needHideDownload = true;
}
return pageData
}
})
Object.defineProperty(unsafeWindow, 'pureViewPageData', {
set: v => pureViewPageData = v,
get() {
if (!pureViewPageData) return pureViewPageData;
// 去除水印,允许继续阅读
if ('customParam' in pureViewPageData) {
pureViewPageData.customParam.noWaterMark = 1;
pureViewPageData.customParam.visibleFoldPage = 1;
}
if ('readerInfo2019' in pureViewPageData) {
pureViewPageData.readerInfo2019.freePage = pureViewPageData.readerInfo2019.page;
}
return pureViewPageData
}
})
}
function addDownloadBtn(wenkuid) {
setTimeout(function(){
if (!unsafeWindow?.readerinfobtn) {
var btn = document.createElement('div');
btn.innerHTML = `<div id="goDownload" class="s-btn-pdf"><div class="s-btn-img" ></div> <span>免费下载文档</span></div>`;
document.body.appendChild(btn);
unsafeWindow.readerinfobtn = true;
document.head.appendChild(document.createElement('style')).innerHTML = `
.s-btn-pdf {
background: #0b1628;
box-shadow: 0 2px 8px 0 #ddd;
border-radius: 23px;
width: 142px;
height: 45px;
line-height: 45px;
text-align: center;
cursor: pointer;
position: fixed;
top: 210px;
right: 42px;
z-index: 999;
}
.s-btn-pdf:hover {
background-color: #fff;
cursor: pointer;
}
.s-btn-pdf span{
font-size: 14px;
color: #d0b276;
line-height: 14px;
font-weight: 700;
}
.s-btn-img {
background: url(https://wkstatic.bdimg.com/static/ndpcwenku/static/ndaggregate/img/gold-arrow-down.2a7dd761ebe866f57483054babe083bd.png) no-repeat;
width: 18px;
height: 18px;
background-position: -1px 5px;
background-size: cover;
display: inline-block;
}
`
}
document.querySelector('#goDownload').onclick = () => {
window.open('http://www.wezhicms.com/index/Tools/index?url='+window.location.href)
}
},2000);
}
addDownloadBtn();
getvip()
})();