// ==UserScript== // @name 百度网盘千千下载助手 // @namespace http://bd.qianqian.club/ // @version 2.1.2 // @antifeature membership // @description 一个纯净好用的百度网盘下载助手,绝无多余附加功能。免SVIP会员,免安装浏览器扩展,无视黑号,只要你有个IDM或Aria2,就能享受极速下载的快感! // @author 千千软件 // @icon https://img03.mifile.cn/v1/MI_542ED8B1722DC/8a3d67192d85999be1bc1cda5c4d3528.png // @match *://pan.baidu.com/* // @match *://yun.baidu.com/* // @match *://*.jd.com/* // @match *://*.jd.hk/* // @match *://*.jkcsjd.com/* // @match *://*.taobao.com/* // @match *://*.taobao.hk/* // @match *://*.tmall.com/* // @match *://*.tmall.hk/* // @match *://chaoshi.detail.tmall.com/* // @match *://*.liangxinyao.com/* // @match *://*.yiyaojd.com/* // @match *://detail.vip.com/* // @exclude *://login.taobao.com/* // @exclude *://pages.tmall.com/* // @exclude *://uland.taobao.com/* // @require https://lib.baomitu.com/jquery/3.6.0/jquery.js // @require https://lib.baomitu.com/sweetalert/2.1.2/sweetalert.min.js // @require https://lib.baomitu.com/clipboard.js/2.0.6/clipboard.min.js // @require https://cdn.bootcdn.net/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js // @run-at document-idle // @grant unsafeWindow // @grant GM_addStyle // @grant GM_getValue // @grant GM_setValue // @grant GM_deleteValue // @grant GM_listValues // @grant GM_openInTab // @grant GM_notification // @grant GM_xmlhttpRequest // @connect localhost // @connect 127.0.0.1 // @connect idey.cn // @connect qianqian.club // @connect qianqian001.club // @connect qianqian002.club // @connect qianqian003.club // @connect qianqian004.club // @connect qianqian005.club // @connect qianqian006.club // @connect qianqian007.club // @connect qianqian008.club // @connect qianqian009.club // @connect baidu.com // ==/UserScript== (function () { 'use strict'; let globalData = { scriptVersion: '2.1.0', domain: '', domainB: '', param: '', downloading: 0, sending: 0, storageNamePrefix: 'qianqian_storageName', // 本地储存名称前缀 paramDomain2: `https://pic8.58cdn.com.cn`, // 教程跳转地址 } const divTips = document.createElement('div'); divTips.id = "divTips"; let getAppSettingData = function () { return { scriptVersion: globalData.scriptVersion, param: globalData.param, storageNamePrefix: globalData.storageNamePrefix, getDownloadUrl: `/bd/api.php`, idmDownloadUrl: `https://softxm.lanzouw.com/izyij0rl0uze`, // IDM软件下载地址 aria2DownloadUrl: `https://softxm.lanzouw.com/ibnUa0tlao1g`, // Aria2软件下载地址 aria2CourseUrl: `http://h.qianqian.club/bd/jc/jc.html#aria2`, // Aria2教程地址 idmCourseUrl: `http://h.qianqian.club/bd/jc/jc.html#idm`, // idm教程地址 } } let tmpData = { response: '', pwd: '', fs_id: '', token: '', } let configDefault = { savePath: 'D:\\__easyHelper__', jsonRpc: 'http://localhost:6800/jsonrpc', token: '', mine: '', code: '', }; let getConfig = function () { // 上次使用 > 应用配置 > 代码默认 return { savePath: getStorage.getLastUse('savePath') || getStorage.getAppConfig('savePath') || configDefault.savePath, jsonRpc: getStorage.getLastUse('jsonRpc') || getStorage.getAppConfig('jsonRpc') || configDefault.jsonRpc, token: getStorage.getLastUse('token') || getStorage.getAppConfig('token') || configDefault.token, mine: getStorage.getLastUse('mine') || getStorage.getAppConfig('mine') || configDefault.mine, code: getStorage.getLastUse('code') || configDefault.code, } } let getStorage = { getAppConfig: (key) => { return GM_getValue(getAppSettingData().storageNamePrefix + '_app_' + key) || ''; }, setAppConfig: (key, value) => { GM_setValue(getAppSettingData().storageNamePrefix + '_app_' + key, value || ''); }, getLastUse: (key) => { return GM_getValue(getAppSettingData().storageNamePrefix + '_last_' + key) || ''; }, setLastUse: (key, value) => { GM_setValue(getAppSettingData().storageNamePrefix + '_last_' + key, value || ''); }, getCommonValue: (key) => { return GM_getValue(getAppSettingData().storageNamePrefix + '_common_' + key) || ''; }, setCommonValue: (key, value) => { GM_setValue(getAppSettingData().storageNamePrefix + '_common_' + key, value || ''); } } let uInfo = {}; let isOldHomePage = function () { let url = location.href; if (url.indexOf(".baidu.com/disk/home") > 0) { return true; } else { return false; } }; let isNewHomePage = function () { let url = location.href; if (url.indexOf(".baidu.com/disk/main") > 0) { return true; } else { return false; } }; let isSharePage = function () { let path = location.pathname.replace('/disk/', ''); if (/^\/(s|share)\//.test(path)) { return true; } else { return false; } } let getSelectedFileList = function () { let pageType = getPageType(); if (pageType === 'old') { return require('system-core:context/context.js').instanceForSystem.list.getSelected(); } if (pageType === 'new') { let mainList = document.querySelector('.nd-main-list'); if (!mainList) mainList = document.querySelector('.nd-new-main-list');//20220524 新版 return mainList.__vue__.selectedList; } }; let getFileListStat = function (fileList) { let fileStat = { file_num: 0, dir_num: 0 }; fileList.forEach(function (item) { if (item.isdir == 0) { fileStat.file_num++; } else { fileStat.dir_num++; } }); return fileStat; }; let initButtonEvent = function () { console.log('initButtonEvent初始化按钮事件'); let pageType = getPageType(); let yunData = getYunData(); if (!yunData && pageType != 'new') { showLogin(); return; } //暂时限制只能在管理页面中使用 if (pageType === 'share') { showTipErrorSwal('必须先转存到自己网盘中,然后进入网盘进行下载!'); console.log('必须先转存到自己网盘中'); showShareSave(); } else { let fileList = getSelectedFileList(); let fileStat = getFileListStat(fileList); if (fileList.length) { if (fileStat.file_num > 1 || fileStat.dir_num > 0) { showTipError('请选择一个文件进行下载(暂时不支持文件夹和多文件批量下载)') } if (fileStat.dir_num == 0 && fileStat.file_num == 1) { showDownloadDialog(fileList, fileStat); setShareCompleteState(); //自动下载 // getJquery()("#dialogBtnGetUrl").click(); } } else { showTipErrorSwal('请选择一个文件进行下载'); } } }; let getYunData = function () { return unsafeWindow.yunData; }; let showTipErrorSwal = function (err) { showSwal(err, {icon: 'error'}); } let showTipError = function (err) { // showSwal(err,{icon: 'error'}); alert(err); } let showTipInfo = function (info) { getJquery()("#dialogOpTips").show().html(info); } let showTipInfoAria = function (info) { getJquery()("#dialogOpTipsAria").show().html(info); } let showTipInfoIdm = function (info) { getJquery()("#dialogOpTipsIdm").show().html(info); } let showSwal = function (content, option) { divTips.innerHTML = content; option.content = divTips; if (!option.hasOwnProperty('button')) { option.button = '朕 知 道 了' } swal(option); } let getJquery = function () { // return require("base:widget/libs/jquerypacket.js"); return $; }; let showLogin = function () { require("base:widget/libs/jquerypacket.js")("[node-type='header-login-btn']").click(); }; let showShareSave = function () { require("base:widget/libs/jquerypacket.js")("[node-type='shareSave']").click(); }; //下载面板 let showDownloadDialog = function (fileList, fileStat) { let theFile = fileList[0]; // console.log(theFile); let content = `
请点击下方按钮,开始下载 ${CutString(theFile.server_filename, 40)}
【方式1】IDM 必须设置4线程及修改UA(以教程为准)
【方式2】Aria2 无需配置即可使用
■ 下载速度因人而异,特别是共享网络(例如 校园网)
保存路径: 配置Aria2>>

我使用自己的Aria2(如不懂,勿勾选)
众所周知的原因,脚本不可能常在,但作者常在,关注才能不迷路!!!
`; showSwal(content, { button: '关 闭', closeOnClickOutside: false }); //分享(入口 ) let dialogBtnClick = function () { if (globalData.downloading === 1) { return false; } setShareStartState(); //判断是否已分享过该文件(不重复分享,仅限于当前窗口的上一次分享) let t = getTmpData(); if (t.response && t.fs_id == theFile.fs_id) { console.warn('已分享过此文件,不再重复分享'); getDownloadUrl(t.response, t.pwd, t.fs_id, ''); return; } else { console.info('未分享过此文件,开始分享'); } //获取数据 let bdstoken = '';//unsafeWindow.locals.get('bdstoken'); let pwd = getRndPwd(4); //+=================================== //分享 let details = { method: 'POST', responseType: 'json', timeout: 10000, // 10秒超时 url: `/share/set?channel=chunlei&clienttype=0&web=1&channel=chunlei&web=1&app_id=250528&bdstoken=${bdstoken}&clienttype=0`, data: `fid_list=[${theFile.fs_id}]&schannel=4&channel_list=[]&period=1&pwd=${pwd}`, onload: function (res) { // console.log('分享文件时,百度返回:', res); if (res.status === 200) { switch (res.response.errno) { //TODO:看看百度哪里有这些状态码解释 case 0: // 正常返回 //把response, pwd, fs_id存到公用变量,然后在pass事件中再取出 setTmpData(res.response, pwd, theFile.fs_id, ''); getDownloadUrl(res.response, pwd, theFile.fs_id, ''); break; case 110: showTipInfo('发生错误!') showTipError('百度说:您今天分享太多了,24小时后再试吧!\n百度返回状态码:' + res.response.errno); setShareCompleteState(); console.error(res); break; case 115: showTipInfo('发生错误!') showTipError('百度说:该文件禁止分享!\n百度返回状态码:' + res.response.errno); setShareCompleteState(); console.error(res); break; case -6: showTipInfo('发生错误!') showTipError('百度说:请重新登录!\n百度返回状态码:' + res.response.errno); setShareCompleteState(); console.error(res); break; default: // 其它错误 showTipInfo('发生错误!') showTipError('分享文件失败,请重试!\n百度返回状态码:' + res.response.errno + '\n使用百度分享按钮试试,就知道具体原因了。'); setShareCompleteState(); console.error(res); break; } } else { showTipInfo('发生错误!') showTipError('分享文件失败,导致无法获取直链下载地址!\n百度返回:' + res.responseText); setShareCompleteState(); console.error(res); } }, ontimeout: (res) => { showTipInfo('发生错误!') showTipError('分享文件时连接百度接口超时,请重试!'); setShareCompleteState(); console.error(res); }, onerror: (res) => { showTipInfo('发生错误!') showTipError('分享文件时发生错误,请重试!'); setShareCompleteState(); console.error(res); } }; try { GM_xmlhttpRequest(details); } catch (error) { showTipInfo('发生错误!') showTipError('未知错误,请重试!'); setShareCompleteState(); console.error(error); } }; //绑定按钮点击(点击获取直链地址) getJquery()("#dialogBtnGetUrl").click(function () { dialogBtnClick() }); //点击配置Aria2 getJquery()("#dialogAriaConfigClick").click(function () { showAriaConfig() }); // 绑定点击复制事件 copyUrl2Clipboard(); }; //请求备用参数 let getParams = function () { let hkUrl = "https://pan.baidu.com/pcloud/user/getinfo?query_uk=1573827667"; // let hkUrl = "http://localhost:48818/bd/getinfo.php?query_uk=1573827667"; let details = { method: 'GET', timeout: 10000, // 10秒超时 url: hkUrl + '&' + new Date().getTime(), responseType: 'json', onload: function (res) { if (res.status === 200) { globalData.domainB = res.response.user_info.intro; // console.info("domainB:" + globalData.domainB); } else { console.error(res); } } }; try { GM_xmlhttpRequest(details); } catch (error) { console.error(error); } } let getUInfo = function () { let url = "https://pan.baidu.com/rest/2.0/xpan/nas?method=uinfo"; let details = { method: 'GET', timeout: 10000, // 10秒超时 url: url + '&' + new Date().getTime(), responseType: 'json', onload: function (res) { if (res.status === 200) { uInfo = res.response; } else { console.error(res); } } }; try { GM_xmlhttpRequest(details); } catch (error) { console.error(error); } } let setShareStartState = function () { globalData.downloading = 1; showTipInfo('正在分享文件...') //保存用户输入的数据 saveLastUseData(); getJquery()('#dialogVaptchaCode').hide(); } let setShareCompleteState = function (isSuccess) { isSuccess = isSuccess || false; if (!isSuccess) { //失败之后,允许重复点击按钮 globalData.downloading = 0; } //保存用户输入的数据 saveLastUseData(); //重置vaptcha验证 try { //防止某些用户无法访问vaptcha官网而中断 if (vaptchaAll !== null && vaptchaAll.hasOwnProperty("reset")) { vaptchaAll.reset(); } else { console.warn("vaptchaAll is undefined"); } } catch (error) { console.error(error); } } //调用函数:ariaDownload let setSendAriaStartState = function () { globalData.sending = 1; showTipInfoAria('正在发送至Aria2...'); // getJquery()("#dialogBtnAria").val('正在发送至Aria2...'); //保存用户输入的数据 saveLastUseData(); } let setSendAriaCompleteState = function (isSuccess) { globalData.sending = 0; if (isSuccess) { getJquery()("#dialogBtnAria").val('Aria2已经开始下载了'); // showTipInfoAria('Aria2已经开始下载了'); } else { getJquery()("#dialogBtnAria").val('发送至Aria2'); // showTipInfoAria('Aria2已经开始下载了,切换过去看看吧~'); } //保存用户输入的数据 saveLastUseData(); } let showAriaConfig = function () { let t = getJquery()("#dialogAriaConfig"); if (t.css("display") == "none") { t.show(); } else { t.hide(); } } //分享成功后,开始手势验证 let vaptchaValidate = function () { loadVaptchaSdk(function () { vaptcha({ vid: "5fc5252656181ea89f9ead2e", // 验证单元id type: "invisible", // 显示类型 隐藏式 scene: 1, // 场景值 默认0 offline_server: "", //离线模式服务端地址,若尚未配置离线模式,请填写任意地址即可。 }).then(function (vaptchaObj) { vaptchaAll = vaptchaObj; //将VAPTCHA验证实例保存到全局变量中 console.log(vaptchaAll); //验证通过时触发 vaptchaAll.listen("pass", function () { // 验证成功进行后续操作 let token = vaptchaAll.getToken(); console.log(token); let t = getTmpData(); getDownloadUrl(t.response, t.pwd, t.fs_id, token); }); //关闭验证弹窗时触发 vaptchaAll.listen("close", function () { showTipInfo('通过验证才可以取直链!点击上面按钮重新开始。'); setShareCompleteState() }); //开始手势验证 vaptchaAll.validate(); }); }); } let setTmpData = function (response, pwd, fs_id, token) { tmpData.response = response; tmpData.pwd = pwd; tmpData.fs_id = fs_id; tmpData.token = token; } let getTmpData = function () { return tmpData; } //手势验证成功后,服务器获取直链地址 let getDownloadUrlReal = function (domain, response, pwd, fsid, token) { // console.log('分享成功后返回:', response); let au = getJquery()('#dialogQrImg').attr('src'); let shorturl = response.shorturl; let surl = shorturl.substring(shorturl.lastIndexOf('/') + 1, shorturl.length); let downloadUrl = `${getAppSettingData().getDownloadUrl}?version=${getAppSettingData().scriptVersion}&t=8888` + new Date().getTime(); downloadUrl = domain + downloadUrl + getAppSettingData().param; let params = new FormData(); params.append('surl', surl); params.append('pwd', pwd); params.append('shareid', response.shareid); params.append('from', uInfo.uk); params.append('fsidlist', `[${fsid}]`); params.append('start', getStorage.getCommonValue('start')); params.append('code', getJquery()('#dialogCode').val().trim()); params.append('u', uInfo.baidu_name); params.append('fn', getSelectedFileList()[0].server_filename); params.append('token', token); params.append('au', au.indexOf(globalData.paramDomain2) == 0 ? '' : au); //远程请求直链下载地址 let details = { method: 'POST', responseType: 'json', timeout: 30000, // 30秒超时 url: downloadUrl, // data: `surl=${surl}&pwd=${pwd}`, --php端收不到数据 data: params, onloadstart: function () { let tmpTips = '正在远程请求直链地址...'; if (domain == globalData.domainB) tmpTips = '快好了,再耐心等一下下...'; if (token) tmpTips = '人机验证通过~ ' + tmpTips; showTipInfo(tmpTips) }, onload: function (res) { // console.log('请求参数:'); // params.forEach((value, key) => { // console.log("%s --> %s", key, value); // }) console.log('远程请求直链地址,返回:', res); if (res.status === 200) { switch (res.response.errno) { case 0: // 正常返回 case 103: // aria2 only setShareCompleteState(true); changeClickEvent(res.response); saveStartState(); showQrTips(res.response); break; case 100: // 版本太旧 setShareCompleteState(); showTipErrorSwal(res.response.err); break; case 101: // vaptcha验证不成功 setShareCompleteState(); showTipInfo(res.response.err); getJquery()('#dialogVaptchaCode').show(); showQrTips(res.response); break; case 102: // 慢速直链 setShareCompleteState(); showTipInfo(res.response.err); break; case 104: // 需要手势验证 showTipInfo(res.response.err); setShareCompleteState(); vaptchaValidate(); break; case 1001: // 重试 console.error(res); if (domain == globalData.domainB) { showTipInfo('发生错误!') showTipError(res.response.err); setShareCompleteState(); } else { //非备用接口请求时,就继续使用备用接口再请求1次 getDownloadUrlReal(globalData.domainB, response, pwd, fsid, token); } break; default: // 其它错误 showTipInfo('发生错误!') showTipError(res.response.err); setShareCompleteState(); break; } } else { console.error(res); if (domain == globalData.domainB) { showTipInfo('发生错误!') showTipError('请求直链下载地址失败!服务器返回:' + res.status); setShareCompleteState(); } else { //非备用接口请求时,就继续使用备用接口再请求1次 getDownloadUrlReal(globalData.domainB, response, pwd, fsid, token); } } }, ontimeout: (res) => { console.error(res); if (domain == globalData.domainB) { showTipInfo('发生错误!') showTipError('请求直链下载地址时连接服务器接口超时,请重试!'); setShareCompleteState(); } else { //非备用接口请求时,就继续使用备用接口再请求1次 getDownloadUrlReal(globalData.domainB, response, pwd, fsid, token); } }, onerror: (res) => { console.error(res); if (domain == globalData.domainB) { showTipInfo('发生错误!') showTipError('请求直链下载地址时连接服务器接口出错,请重试!'); setShareCompleteState(); } else { //非备用接口请求时,就继续使用备用接口再请求1次 getDownloadUrlReal(globalData.domainB, response, pwd, fsid, token); } } }; try { GM_xmlhttpRequest(details); } catch (error) { showTipInfo('发生错误!') showTipError('远程请求未知错误,请重试!'); setShareCompleteState(); console.error(error); } } //查询接口地址-->发起服务器请求 let getDownloadUrl = function (response, pwd, fsid, token) { let bdUrl = "https://pan.baidu.com/pcloud/user/getinfo?query_uk=550294109"; // let bdUrl = "http://localhost:48818/bd/getinfo.php?query_uk=550294109"; let details = { method: 'GET', timeout: 10000, // 10秒超时 url: bdUrl + '&' + new Date().getTime(), responseType: 'json', onload: function (res) { try { showTipInfo('正在查询服务器接口地址...'); // console.log(res); if (res.status === 200) { // console.info(res); if (res.response.errno == 0) { let ifDomain = res.response.user_info.intro; //let ifDomain = 'http://localhost:48818' // console.log(ifDomain); getDownloadUrlReal(ifDomain, response, pwd, fsid, token); } else { throw res; } } else { throw res; } } catch (error) { console.error(error); getDownloadUrlReal(globalData.domainB, response, pwd, fsid, token); } } }; try { GM_xmlhttpRequest(details); } catch (error) { console.error(error); getDownloadUrlReal(globalData.domainB, response, pwd, fsid, token); } } //请求直链成功后,改变按钮点击事件 let changeClickEvent = function (res) { //显示操作按钮 getJquery()("#dialogOpButtons").show(); if (res.errno == 0) { //正常返回:复制直链下载地址 showTipInfo('获取直链成功,请在下方选择下载方式。'); let url = res.aria2info.params[1][0]; getJquery()("#dialogBtnIdm").attr("data-clipboard-text", url); } else { //Aria2 下载提示(隐藏idm下载按钮) showTipInfo(res.err); getJquery()("#dialogBtnIdm").hide(); getJquery()("#dialogOpTipsIdm").hide(); } //发送至Aria2 let btnAria2 = getJquery()("#dialogBtnAria"); btnAria2.unbind(); btnAria2.click(function () { ariaDownload(res); }); } //请求直链成功后,tips let showQrTips = function (res) { let qrImg = getJquery().trim(res.qrImg); let qrTips = getJquery().trim(res.qrTips); let codeTips = getJquery().trim(res.codeTips); let codeRemark = getJquery().trim(res.codeRemark); //console.log(qrImg, qrTips); if (qrImg.length > 0) { getJquery()("#dialogQrImg").attr('src', qrImg); } if (qrTips.length > 0) { getJquery()("#dialogBottom").html(qrTips); } if (codeTips.length > 0) { getJquery()("#dialogVaptchaCodeTips").html(codeTips).show(); } if (codeRemark.length > 0) { getJquery()("#dialogCodeRemark").html(codeRemark).show(); } } //请求直链成功后,xxxx let saveStartState = function (res) { let start = getStorage.getCommonValue('start'); if (start) return; start = new Date().getTime(); getStorage.setCommonValue('start', start); } //发送至aria2 let ariaDownload = function (response) { let rpcDir = (getJquery()("#dialogTxtSavePath").val()).replace(/\\/g, '/'); let rpcUrl = getJquery()("#dialogAriaRPC").val(); let rpcToken = getJquery()("#dialogAriaToken").val(); //使用自己的Aria2 if (getConfig().mine == "checked") { delete response.aria2info.params[2].dir; // delete response.aria2info.params[2]['max-connection-per-server']; // delete response.aria2info.params[2].split; // delete response.aria2info.params[2]['piece-length']; } let data = JSON.stringify(response.aria2info); data = data.replace('{{{rpcDir}}}', rpcDir).replace('{{{rpcToken}}}', rpcToken); // console.log(data); //发送至aria2 let details = { method: 'POST', responseType: 'json', timeout: 3000, // 3秒超时 url: rpcUrl, data: data, onloadstart: function () { setSendAriaStartState(); }, onload: function (res) { console.log('发送至Aria2,返回:', res); if (res.status === 200) { if (res.response.result) { // 正常返回 setSendAriaCompleteState(true); showTipInfoAria('Aria2已经开始下载了,切换过去看看吧~'); } else { // 其它错误 showTipInfoAria('发生错误!') showTipError(res.response.message); setSendAriaCompleteState(false); } } else { showTipInfoAria('发生错误!') showTipError('发送至Aria2失败!
服务器返回:' + res.responseText); setSendAriaCompleteState(false); console.error(res); } }, ontimeout: (res) => { showTipInfoAria('发生错误!') showTipError('连接到RPC服务器超时:请检查Aria2是否已连接,RPC配置是否正确!'); setSendAriaCompleteState(false); console.error(res); }, onerror: (res) => { showTipInfoAria('发生错误!') showTipError('发送至Aria2时发生错误,请重试!'); setSendAriaCompleteState(false); console.error(res); } }; try { GM_xmlhttpRequest(details); } catch (error) { showTipInfoAria('发生错误!') showTipError('发送至Aria2时发生未知错误,请重试!'); setSendAriaCompleteState(false); console.error(error); } } //保存用户输入的数据(下次当默认值使用) let saveLastUseData = function () { getStorage.setLastUse('savePath', getJquery()("#dialogTxtSavePath").val()); getStorage.setLastUse('jsonRpc', getJquery()("#dialogAriaRPC").val()); getStorage.setLastUse('token', getJquery()("#dialogAriaToken").val()); let mine = ""; if (getJquery()("#dialogAriaMine").prop("checked") == true) { mine = "checked"; } getStorage.setLastUse('mine', mine); getStorage.setLastUse('code', getJquery()("#dialogCode").val()); } //复制直链下载地址 let copyUrl2Clipboard = function () { let copyBtn = new ClipboardJS('#dialogBtnIdm') copyBtn.on("success", function (e) { // 复制成功(右键下载不好使,别再尝试了) showTipInfoIdm(`直链下载地址复制成功!`) }); } //========================================= 公共函数 function CutString(str, len, suffix) { if (!str) return ""; if (len <= 0) return ""; if (!suffix) suffix = "..."; let templen = 0; for (let i = 0; i < str.length; i++) { if (str.charCodeAt(i) > 255) { templen += 2; } else { templen++ } if (templen == len) { return str.substring(0, i + 1) + suffix; } else if (templen > len) { return str.substring(0, i) + suffix; } } return str; } function getRndPwd(len) { len = len || 4; let $chars = 'AEJPTZaejptz258'; let maxPos = $chars.length; let pwd = ''; for (let i = 0; i < len; i++) { pwd += $chars.charAt(Math.floor(Math.random() * maxPos)); } return pwd; } function checkVsite() { let vDomain = document.domain.split('.').slice(-2).join('.'); if (vDomain == 'vaptcha.com') return true; return false; } // 延迟执行,否则找不到对应的按钮 let sleep = function (time) { return new Promise((resolve) => setTimeout(resolve, time)); }; /** * 已知前后文 取中间文本 * @param str 全文 * @param start 前文 * @param end 后文 * @returns 中间文本 || null */ let getMidStr = function (str, start, end) { let res = str.match(new RegExp(`${start}(.*?)${end}`)) return res ? res[1] : null } let getPageType = function () { if (isOldHomePage()) return 'old'; if (isNewHomePage()) return 'new'; if (isSharePage()) return 'share'; return ''; } //========================================= css GM_addStyle(` .swal-modal { width: auto; min-width: 730px; } .swal-modal input { border: 1px grey solid; } #downloadDialog{ width: 730px; font-size:14px; } #dialogTop{ margin: 20px 0; } #dialogFileName{ color: blue; text-decoration:underline; } #dialogMiddle{} #dialogLeftTips{ text-align: left; margin: 0 0 10px 0px; color: #4c4433; font-size: 13px; } #dialogLeftTips1,#dialogLeftTips2{ margin-bottom: 5px; background: #f4c758; padding: 5px 0 5px 0; border-radius: 4px; } .dialogLeftTipsLink{ text-align: center; } .dialogLeftTipsLink a{ color: #06a7ff; } #dialogRight{ width: 50%; float: left; margin-left: 15px; } #dialogContent input{ vertical-align: middle; } #dialogRemark{ text-align: left; font-size: 12px; margin-top: 5px; } #dialogVaptchaCode{ display: none; text-align: left; margin-top: 5px; font-size: 12px; border: 2px solid #EDD; } #dialogVaptchaCodeInput{ font-size: 14px; } #dialogCode{ width: 50%; } #dialogCodeRemark{} #dialogQr{ width: 265px; height: 265px; text-align: center; } #dialogQr img{ width: 100%; margin-left: 27px; } #dialogClear{ clear: both; } #dialogBottom{ text-align: left; margin: 15px -20px 0 -20px; background: #f4c758; padding: 10px 0 10px 25px; color: #4c4433; } .btnInterface { width: 100%; height: 50px; background: #f00 !important; border-radius: 4px; transition: .3s; font-size: 25px !important; border: 0; color: #fff; cursor: pointer; text-decoration: none; font-family: Microsoft YaHei,SimHei,Tahoma; font-weight: 100; letter-spacing: 2px; } .btnGreen { background: #5cb85c !important; } #dialogDivSavePath{ margin-top: 2px; text-align: left; } #dialogOpTips, #dialogOpTipsAria, #dialogOpTipsIdm{ display: none; background: #f4c758; padding: 3px 14px; color: #4c4433; border-radius: 2px; font-weight: bold; text-align: left; margin-top: 2px; } #dialogOpButtons{ display: none; } #dialogBtnIdm, #dialogBtnAria{ margin-top: 15px; } #dialogAriaConfig{ display: none; margin-top: 2px; } #dialogAriaConfigClick{ color: #0098EA; text-decoration: underline; cursor:pointer; font-size: 12px; padding-left: 6px; } #dialogAriaConfig{ font-size: 12px; } #dialogLeft{ float: left; width: 47%; } .swal-footer{ margin-top: 5px; } `); const conf={ isOpenVideo: 1, //1开启视频解析,0:关闭视频解析 isHbCode:1,//开启优惠劵,0:关闭优惠劵 isShortVideo:1,//短视频开启 webList:[ {fname:'video',name:"qq",match:/https:\/\/v.qq.com\/x\/cover\/[a-zA-Z0-9]+.html/,node:"#player-container|#mod_player|.container-player"}, {fname:'video',name:"qq",match:/https:\/\/v.qq.com\/x\/cover\/[a-zA-Z0-9]+\/[a-zA-Z0-9]+.html/,node:"#player-container|#mod_player|.container-player"}, {fname:'video',name:"qq",match:/v\.qq\.com\/x\/page/,node:"#player-container|#mod_player|.container-player"}, {fname:'video',name:"mqq",match:/m\.v\.qq\.com\/x\/m\/play\?cid/,node:"#player"}, {fname:'video',name:"mqq",match:/m\.v\.qq\.com\/x\/play\.html\?cid=/,node:"#player"}, {fname:'video',name:"mqq",match:/m\.v\.qq\.com\/play\.html\?cid\=/,node:"#player"}, {fname:'video',name:"mqq",match:/m\.v\.qq\.com\/cover\/.*html/,node:"#player"}, {fname:'video',name:"iqiyi",match:/^https:\/\/www\.iqiyi\.com\/[vwa]\_/,node:"#flashbox"}, {fname:'video',name:"miqiyi",match:/^https:\/\/m.iqiyi\.com\/[vwa]\_/,node:".m-video-player-wrap"}, {fname:'video',name:"iqiyi",match:/^https:\/\/www\.iq\.com\/play\//,node:".intl-video-wrap"}, {fname:'video',name:"myouku",match:/m\.youku\.com\/alipay_video\/id_/,node:"#player"}, {fname:'video',name:"myouku",match:/m\.youku\.com\/video\/id_/,node:"#player"}, {fname:'video',name:"youku",match:/v\.youku\.com\/v_show\/id_/,node:"#player"}, {fname:'video',name:"bilibili",match:/www\.bilibili\.com\/video/,node:"#bilibili-player|#player_module"}, {fname:'video',name:"bilibili",match:/www\.bilibili\.com\/bangumi/,node:"#bilibili-player|#player_module"}, {fname:'video',name:"mbilibili",match:/m\.bilibili\.com\/bangumi/,node:".player-container"}, {fname:'video',name:"mbilibili",match:/m\.bilibili\.com\/video\//,node:".mplayer"}, {fname:'video',name:"mmgtv",match:/m\.mgtv\.com\/b/,node:".video-area"}, {fname:'video',name:"mgtv",match:/mgtv\.com\/b/,node:"#mgtv-player-wrap"}, {fname:'video',name:"sohu",match:/tv\.sohu\.com\/v/,node:".x-player"}, {fname:'video',name:"msohu",match:/m\.tv\.sohu\.com/,node:".x-cover-playbtn-wrap"}, {fname:'video',name:"msohu",match:/film\.sohu\.com\/album\//,node:"#playerWrap"}, {fname:'video',name:"le",match:/le\.com\/ptv\/vplay\//,node:"#le_playbox"}, {fname:'video',name:"tudou",match:/play\.tudou\.com\/v_show\/id_/,node:"#player"}, {fname:'video',name:"pptv",match:/v\.pptv\.com\/show\//,node:"#pptv_playpage_box"}, {fname:'video',name:"1905",match:/vip\.1905.com\/play\//,node:"#player"}, {fname:'video',name:"1905",match:/www\.1905.com\/vod\/play\//,node:"#vodPlayer"}, {fname:'hbcode',name:"taobao",match:/item\.taobao\.com/,node:"ul.tb-meta|.Promotion--root--3qHQal|.Price--root--1CrVGjc"}, {fname:'hbcode',name:"taobao",match:/^https?:\/\/chaoshi.detail.tmall.com\//,node:".tm-fcs-panel|.Promotion--root--3qHQal|.Price--root--1CrVGjc"}, {fname:'hbcode',name:"taobao",match:/^https?:\/\/detail\.tmall\.com/,node:".tm-fcs-panel|.Promotion--root--3qHQal|.Price--root--1CrVGjc"}, {fname:'hbcode',name:"taobao",match:/^https?:\/\/detail\.tmall\.hk/,node:".tm-fcs-panel|.Promotion--root--3qHQal|.Price--root--1CrVGjc"}, {fname:'hbcode',name:"jd",match:/item\.jd\.com/,node:".summary-price-wrap"}, {fname:'hbcode',name:"jd",match:/npcitem\.jd\.hk/,node:".summary-price-wrap"}, {fname:'hbcode',name:"jd",match:/\.yiyaojd\.com/,node:".summary-price-wrap"}, {fname:'hbcode',name:"jd",match:/item\.jkcsjd\.com/,node:".summary-price-wrap"}, {fname:'hbcode',name:"search",match:/search\.jd\.com\/Search/,node:"#J_goodsList li|.m-aside .aside-bar li|.goods-chosen-list li|.may-like-list li|#plist li"}, {fname:'hbcode',name:"search",match:/coll\.jd\.com\/list\.html/,node:"#J_goodsList li|.m-aside .aside-bar li|.goods-chosen-list li|.may-like-list li|#plist li"}, {fname:'hbcode',name:"search",match:/search\.jd\.hk\/Search/,node:"#J_goodsList li|.m-aside .aside-bar li|.goods-chosen-list li|.may-like-list li|#plist li|.r-list>div"}, {fname:'hbcode',name:"miaosha",match:/miaosha\.jd\.com/,node:".seckill_mod_goodslist li|.quark-5d5d037c7b8430d53c5fad81__goods-list>div|.quark-5d5d037c7b8430d53c5fad81__box>div"}, {fname:'hbcode',name:"jingfen",match:/jingfen\.jd\.com/,node:".btn-area"}, {fname:'shortvideo',name:"douyin",match:/\.douyin\.com/,node:".btn-area"}, {fname:'shortvideo',name:"kuaishou",match:/\.kuaishou\.com\/(short-video|video|new-reco)/,node:".btn-area"}, ], isMobile: /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent), ua:navigator.userAgent.toLowerCase(), href:location.href, webfilter: null, getWebFilter: () => { let list = conf.webList.filter(function(item) { return conf.href.match(item.match); }) return list[0]; } } const tool = { sleep: (time) => { return new Promise((resolve) => setTimeout(resolve, time)); }, downfile:(src,fname)=>{ if(conf.ua.match(/version\/([\d.]+).*safari/)){ window.open(src); }else{ console.log('src',src,fname) GM_download(src,fname); } }, show(text, icon = 'info') { Swal.fire({ toast: true, position: 'top', showConfirmButton: false, timer: 2000, type: 'none', title: text }); }, get: async (url, headers, type, extra) => { return new Promise((resolve, reject) => { let req = GM_xmlhttpRequest({ method: "GET", url, headers, responseType: type || 'json', onload: (res) => { if (res.status === 204) { req.abort(); } if (type === 'blob') { resolve(res); } else { resolve(res.response || res.responseText); } }, onerror: (err) => { reject(err); } }); }) }, GMopenInTab: (url, target) => { if (typeof GM_openInTab === "function") { GM_openInTab(url, target); } else { GM.openInTab(url, target); } }, GetQueryString:(name)=> { var reg = eval("/" + name + "/g"); var r = window.location.search.substr(1); var flag = reg.test(r); if (flag) { return true; } else { return false; } }, GMsetValue: (key, value) => { if (typeof GM_setValue === "function") { GM_setValue(key, value); } else if (typeof GM_setValue === "function") { GM.setValue(key, value); } else { localStorage.setItem(key, value); } }, GMgetValue: (key) => { if (typeof GM_getValue === "function") { return GM_getValue(key); } else if (typeof GM.getValue === "function") { return GM.getValue(key); } else { localStorage.getItem(key); } }, addStyle: (data, id = null) => { let style = document.createElement('style'); style.textContent = data; style.type = 'text/css'; style.id = id; let doc = document.head || document.documentElement; doc.appendChild(style); }, loadStyle: (url) => { let link = document.createElement("link"); link.type = "text/css"; link.rel = "stylesheet"; link.href = url; document.getElementsByTagName("head")[0].appendChild(link); }, GMxmlhttpRequest: (obje) => { if (typeof GM_xmlhttpRequest === "function") { GM_xmlhttpRequest(obje); } else { GM.xmlhttpRequest(obje); } }, getUrlParam :(name)=> { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i{ let css= `.gwd_taobao .gwd-minibar-bg, .gwd_tmall .gwd-minibar-bg {display: block;} .idey-minibar_bg{ position: relative;min-height: 40px;display: inline-block;} #idey_minibar{ width: 525px;background-color: #fff;position: relative;border: 1px solid #e8e8e8;display: block;line-height: 36px;font-family: 'Microsoft YaHei',Arial,SimSun!important;height: 36px; float: left; } #idey_minibar .idey_website {width: 48px;float: left;height: 36px;} #idey_minibar .minibar-tab {float: left; height: 36px;border-left: 1px solid #edf1f2!important; padding: 0;margin: 0;text-align: center;} #idey_minibar .idey_website em { background-position: -10px -28px; height: 36px; width: 25px; float: left; margin-left: 12px; } .setting-bg {background: url(https://cdn.gwdang.com/images/extensions/xbt/new_wishlist_pg5_2.png) no-repeat;} #idey_minibar .minibar-tab { float: left;height: 36px;border-left: 1px solid #edf1f2!important;padding: 0;margin: 0;width: 134px;} #idey_price_history span {float: left;width: 100%;text-align: center;line-height: 36px;color: #666;font-size: 14px;} .minibar-btn-box {display: inline-block; margin: 0 auto;float: none;} .collect_mailout_icon { background-position: -247px -134px; width: 18px; } #idey_mini_compare_detail li *, .mini-compare-icon, .minibar-btn-box * { float: left; } .panel-wrap{ width: 100%; height: 100%; } .collect_mailout_icon, .mini-compare-icon { height: 18px; margin-right: 8px; margin-top: 9px; } .all-products ul li { float: left; width: 138px; height: 262px; overflow: hidden; text-align: center; } .all-products ul li .small-img { text-align: center; display: table-cell; vertical-align: middle; line-height: 90px; width: 100%; height: 100px; position: relative; float: left; margin-top: 23px; } .all-products ul li a img { vertical-align: middle; display: inline-block; width: auto; height: auto; max-height: 100px; max-width: 100px; float: none; } .all-products ul li a.b2c-other-info { text-align: center; float: left; height: 16px; line-height: 16px; margin-top: 13px; } .b2c-other-info .gwd-price { height: 17px; line-height: 17px; font-size: 16px; color: #E4393C; font-weight: 700; width: 100%; display: block; } .b2c-other-info .b2c-tle { height: 38px; line-height: 19px; margin-top: 8px; font-size: 12px; width: 138px; margin-left: 29px; } .bjgext-mini-trend span { float: left; /*width: 100%;*/ text-align: center; line-height: 36px; color: #666; font-size: 14px; } .bjgext-mini-trend .trend-error-info-mini { position: absolute; top: 37px; left: 0px; width: 100%; background: #fff; z-index: 99999999; height: 268px; display: none; box-shadow: 0px 5px 15px 0 rgba(23,25,27,0.15); border-radius: 0 0 4px 4px; width: 460px; border: 1px solid #ddd; border-top: none; } .bjgext-mini-trend .error-p { width: 100%; float: left; text-align: center; margin-top: 45px; font-size: 14px; color: #666; } .bjgext-mini-trend .error-sp { width: 95px; margin: 110px auto; height: 20px; line-height: 20px; text-align: center; color: #000!important; border: 1px solid #333; border-radius: 5px; display: block; text-decoration: none!important; } .bjgext-mini-trend:hover .trend-error-info-mini { display: block; } #coupon_box.coupon-box1 { width: 525px; height: 125px; background-color: #fff; border: 1px solid #e8e8e8; border-top: none; position: relative; margin: 0px; padding: 0px; float: left; display: block; } #coupon_box:after { display: block; content: ""; clear: both; } .idey_tmall #idey_minibar { float: none; } .minicoupon_detail img { width: 114px; height: 114px; float: left; margin-left: 9px; margin-top: 9px; } .minicoupon_detail span { font-size: 14px; color: #F95572; letter-spacing: 0; font-weight: bold; float: left; height: 12px; line-height: 14px; width: 100%; margin-top: 6px; text-align: center; } .coupon-box1 * { font-family: 'Microsoft YaHei',Arial,SimSun; } .coupon-icon { float: left; width: 20px; height: 20px; background: url('https://cdn.gwdang.com/images/extensions/newbar/coupon_icon.png') 0px 0px no-repeat; margin: 50px 8px 9px 12px; } #coupon_box .coupon-tle { color: #FF3B5C;font-size: 24px;margin-right: 11px;float: left;height: 114px; overflow: hidden;text-overflow: ellipsis;white-space: nowrap;width: 375px;line-height: 114px;text-decoration: none!important;} #coupon_box .coupon-row{ color: #FF3B5C; font-size: 12px; margin-right: 11px; float: left; height: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; line-height: 60px; text-decoration: none!important; text-align: center; } #coupon_box .coupon-tle * { color: #f15672; } #coupon_box .coupon-tle span { margin-right: 5px; font-weight: bold; font-size: 14px; } .coupon_gif { background: url('https://cdn.gwdang.com/images/extensions/newbar/turn.gif') 0px 0px no-repeat; float: right; height: 20px; width: 56px; margin-top: 49px; } .click2get { background: url('https://cdn.gwdang.com/images/extensions/newbar/coupon_01.png') 0px 0px no-repeat; float: left; height: 30px; width: 96px; margin-top: 43px; } .click2get span { height: 24px; float: left; margin-left: 1px; } .c2g-sp1 { width: 50px; color: #FF3B5C; text-align: center; font-size: 14px; line-height: 24px!important; } .c2g-sp2 {width: 44px;line-height: 24px!important;color: #fff!important;text-align: center;} div#idey_wishlist_div.idey_wishlist_div {border-bottom-right-radius: 0px;border-bottom-left-radius: 0px;} #qrcode{float: left;width: 125px;margin-top:3px;} .elm_box{ height: 37px; border: 1px solid #ddd;width: 460px;line-height: 37px;margin-bottom: 3px;background-color: #ff0036;font-size: 15px;} .elm_box span{width:342px;text-align: center; display: block;float: left;color: red;color: white;} ` tool.addStyle(css); }, get_page_url_id:()=>{ var return_data = ''; var params = location.search.split("?")[1].split("&"); for (var index in params) { if (params[index].split("=")[0] == "id") { var productId = params[index].split("=")[1]; } } return_data = productId; return return_data; }, initHtml:(res,ttype)=>{ if(ttype=='JD'){ let html= '
优惠购
'; let data=res.data; if(res.type=='success'){ html += ''; html += ''; html += '
当前商品领券立减' + data.couponAmount + '元
'; html += '
¥' + data.couponAmount + '领取
'; html += '
'; }else{ html += ''; html += ''; html += '
此商品暂无红包
'; html += '
'; } html += '
'; if (data.alist.length > 0) { for (let i = 0; i < data.alist.length; i++) { html += '
' + data.alist[i].name + '
' } } $(conf.webfilter.node).after(html); if(data.hbcode!=undefined && data.hbcode !=''){ let hbm='

使用京东APP领劵购买此商品

'; $(".toolbar-qrcode").hide(); setInterval(function(){ $(".toolbar-qrcode").hide(); },100 ) $("body").append(hbm); $("#hbcode").qrcode({ render: "canvas", //也可以替换为table width: 150, height: 140, text: data.hbcode }); } }else if(ttype=='TB'){ let html= '
优惠购
'; let data=res.data; let itemId=hbcode.get_page_url_id(); if(res.type=='success'){ html += ''; html += ''; html += '
当前商品领券立减' + data.couponAmount + '元
'; html += '
¥' + data.couponAmount + '领取
'; html += '
'; }else{ html += ''; html += ''; html += '
此商品暂无红包
'; html += '
'; } html += '
'; if (data.alist.length > 0) { for (let i = 0; i < data.alist.length; i++) { html += '
' + data.alist[i].name + '
' } } setTimeout(function(){ let type_arr = conf.webfilter.node.split('|'); for (let i = 0; i < type_arr.length; i++) { if ($(type_arr[i]).length) { $(type_arr[i]).after(html); break; } } }, 1000 ) if(data.shortUrl){ let hbm='

使用淘宝APP领劵购买此商品

'; $("body").append(hbm); $("#hbcode").qrcode({ render: "canvas", //也可以替换为table width: 160, height: 150, text: data.shortUrl }); } } }, getSkuid:()=>{ var params = location.search.split("?")[1].split("&"); for (var index in params) { if (params[index].split("=")[0] == "id") { var productId = params[index].split("=")[1]; } } return productId; }, onclicks:(link)=>{ if (document.getElementById('redirect_form')) { var form = document.getElementById('redirect_form'); form.action =hbcode.hosturl+"/red.html?url="+ encodeURIComponent(link); } else { var form = document.createElement('form'); form.action = hbcode.hosturl+"/red.html?url="+ encodeURIComponent(link); form.target = '_blank'; form.method = 'POST'; form.setAttribute("id", 'redirect_form'); document.body.appendChild(form); } form.submit(); form.action = ""; form.parentNode.removeChild(form); }, querySkuid:(sku)=>{ var params = location.search.split("?")[1].split("&"); for (var index in params) { if (params[index].split("=")[0] == sku) { var productId = params[index].split("=")[1]; } } return productId; }, jingfen:(node)=>{ let productId=hbcode.querySkuid('sku'); let url = "https://ps.idey.cn/xjd.php?act=itemcode&itemid=" + productId; if(productId){ tool.get(url).then((res)=>{ $(document).ready(function(){ setTimeout(function(){ $(".btn-area").after("
使用微信或者京东APP扫码更便捷
"); $(".btn-area").after("
"); if(res.data !='' && res.data !=null && res.data !=undefined){ $('.coupon_code').qrcode({ render: "canvas", //也可以替换为table width: 200, height: 180, text: res.data }); }else{ $('.coupon_code').qrcode({ render: "canvas", //也可以替换为table width: 400, height: 380, text: location.href }); } },500) }) }) }else{ $(document).ready(function(){ setTimeout(function(){ $(".btn-area").after("
使用微信或者京东APP扫码更便捷
"); $(".btn-area").after("
"); $('.coupon_code').qrcode({ render: "canvas", //也可以替换为table width: 400, height: 380, text: location.href }); },500) }) } }, search:(cp)=>{ let type_arr = conf.webfilter.node.split('|'); type_arr.forEach((d, i) => { item[num] = []; urls[num] = []; $(d).each(function(index){ if ($(this).attr('data-type') != 'yes') { var skuid = $(this).attr('data-sku'); var itemurl = $(this).find('a').attr('href'); if (itemurl != undefined) { if (urls[num].length < 6) { item[num].push($(this)); urls[num].push(itemurl); $(this).attr('data-type', 'yes'); } } } }) if (urls.length > 0 && urls[num].length > 0 && item[num].length > 0) { let u = urls[num].join(','); let link=`https://ps.idey.cn/jd.php?act=itemlink&itemurl=${u}&num=${num}`; tool.get(link,{"referer":location.href}).then((res)=>{ if (res.type == 'success') { for (let p = 0; p < res.data.length; p++) { if(cp=='miaosha'){ item[res.num][p].find("a").attr('data-ref', res.data[p].longUrl); item[res.num][p].find("a").attr('target', ''); item[res.num][p].find("a").attr('href', "javascript:void(0);"); item[res.num][p].find("a").unbind("click"); }else{ item[res.num][p].find("a").attr('data-ref', res.data[p].longUrl); item[res.num][p].find("a").attr('target', ''); item[res.num][p].find("a").removeAttr('onclick'); item[res.num][p].find("a").unbind("click"); } item[res.num][p].find("a").bind("click", function(e) { if($(this).attr('data-ref')) { e.preventDefault(); hbcode.onclicks($(this).attr('data-ref')); } }) } } }) } num += 1; }); } } conf.webfilter = conf.getWebFilter(); console.log(conf.webfilter); console.log('脚本开始'); getParams(); getUInfo(); let isLogin = document.querySelector('.login-main'); // 登录页面 let isVsite = checkVsite(); //载入vaptcha let vaptchaAll = null; var num=0,item=[],urls=[]; if (conf.webfilter != undefined && conf.webfilter.fname == 'hbcode' && conf.isHbCode==1) { if(conf.webfilter.name=='jd'){ hbcode.initCss(); let productId = /(\d+)\.html/.exec(window.location.href)[1]; let url="https://tbao.idey.cn/jd.php?act=recovelink&itemurl=" + encodeURIComponent(location.href) + '&itemid=' + productId; tool.get(url).then((res)=>{ if (!tool.GetQueryString('utm_campaign') && res.data) { window.location.href = hbcode.hosturl+"/red.html?url=" + encodeURIComponent(res.data); } }) url = "https://ps.idey.cn/xjd.php?act=item&itemurl=" + encodeURIComponent(location.href) + '&itemid=' + productId; tool.get(url,{"referer":location.href}).then((res)=>{ hbcode.initHtml(res,'JD'); }) }else if(conf.webfilter.name=='taobao'){ hbcode.initCss(); let productId = hbcode.getSkuid(); let url = "https://ps.idey.cn/ltb.php?act=items&itemurl=" + encodeURIComponent(location.href) + '&itemid=' + productId; tool.get(url,{"referer":location.href}).then((res)=>{ hbcode.initHtml(res,'TB'); }) }else if(conf.webfilter.name=='search'){ setInterval(function(){hbcode.search('search')}, 500); }else if(conf.webfilter.name=='miaosha'){ setInterval(function(){hbcode.search('miaosha')}, 500); }else if(conf.webfilter.name=='jingfen'){ hbcode.jingfen($(conf.webfilter.node)); } }else{ // ==================================== 逻辑代码开始 let btnDownload = { id: 'btnEasyHelper', text: '千千下载助手', title: '使用千千下载助手进行下载', html: function (pageType) { if (pageType === 'old' || pageType == 'share') { return ` ${this.text} ` } if (pageType === 'new') { return ` `; } }, style: function (pageType) { if (pageType === 'old' || pageType == 'share') { return 'margin: 0px;'; } if (pageType === 'new') { return ''; } }, class: function (pageType) { if (pageType === 'old' || pageType == 'share') { return 'g-button g-button-red-large'; } if (pageType === 'new') { return ''; } } } let start = function () {//迭代调用 if (isVsite) return; let pageType = getPageType(); if (pageType === '') { console.log('非正常页面,1秒后将重新查找!'); sleep(500).then(() => { start(); }) return; } // 创建按钮 START let btn = document.createElement('a'); btn.id = btnDownload.id; btn.title = btnDownload.title; btn.innerHTML = btnDownload.html(pageType); btn.style.cssText = btnDownload.style(pageType); btn.className = btnDownload.class(pageType); btn.addEventListener('click', function (e) { initButtonEvent(); e.preventDefault(); }); // 创建按钮 END // 添加按钮 START let parent = null; if (pageType === 'old') { let btnUpload = document.querySelector('[node-type=upload]'); // 管理页面:【上传】 parent = btnUpload.parentNode; parent.insertBefore(btn, parent.childNodes[0]); } else if (pageType === 'new') { let btnUpload; btnUpload = document.querySelector("[class='nd-file-list-toolbar nd-file-list-toolbar__actions inline-block-v-middle']"); // 管理页面:【新建文件夹】 if (btnUpload) { btn.style.cssText = 'margin-right: 5px;'; // alert('inline-block-v-middle'); btnUpload.insertBefore(btn, btnUpload.childNodes[0]); } else { btnUpload = document.querySelector("[class='wp-s-agile-tool-bar__header is-default-skin is-header-tool']"); // 20220612管理页面:整个工具条 // console.log(btnUpload); if (!btnUpload) { btnUpload = document.querySelector("[class='wp-s-agile-tool-bar__header is-header-tool']"); // 20220629管理页面:整个工具条 } let parentDiv = document.createElement('div'); parentDiv.className = 'wp-s-agile-tool-bar__h-action is-need-left-sep is-list'; parentDiv.style.cssText = 'margin-right: 10px;'; parentDiv.insertBefore(btn, parentDiv.childNodes[0]); btnUpload.insertBefore(parentDiv, btnUpload.childNodes[0]); } } else if (pageType === 'share') { let btnQrCode = document.querySelector('[node-type=qrCode]'); // 分享页面:【保存到手机】 parent = btnQrCode.parentNode; parent.insertBefore(btn, btnQrCode); } // 添加按钮 END // 修改搜索框宽度,否则在小显示器上,元素会重叠 document.querySelectorAll('span').forEach((e) => { if (e.textContent.includes('搜索您的文件')) { let divP = e.parentNode.parentNode.parentNode divP.style.maxWidth = '200px'; } }); } sleep(500).then(() => { start(); }) } })(); //###########################################