// ==UserScript== // @name 网盘精灵 // @version 1.0.0 // @description 网盘精灵,云盘、网盘搜索工具,提供了资源搜索功能,支持百度云盘、新浪微盘、蓝奏云盘的提取码获取,自动填充,为你提供便捷的资源搜索服务。 // @license AGPL // @match *://pan.baidu.com/* // @match *://yun.baidu.com/* // @match *://*.lanzoux.com/* // @match *://*.lanzous.com/* // @match *://vdisk.weibo.com/* // @require https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js // @require https://cdn.jsdelivr.net/npm/sweetalert2@10.10.0/dist/sweetalert2.all.min.js // @connect * // @run-at document-idle // @namespace https://greasyfork.org/users/215071 // @downloadURL none // ==/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); }, }); //监听点击提取按钮,存储提取码 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 != "文件名") { 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) { 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) { //单文件(有提取码) 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')) { //多文件(有提取码) 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 interval = setInterval(function () { if (window.document.querySelectorAll('.d div').length > 0) { clearInterval(interval); 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); } } //百度网盘去广告 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); })()