Professional Documents
Culture Documents
// @name EX-百度云盘
// @namespace https://github.com/gxvv/ex-baiduyunpan/
// @version 0.3.3
// @description [下载大文件] [批量下载] [文件夹下载] [百度网盘] [百度云盘] [企业版]
// @description [baidu] [baiduyun] [yunpan] [baiduyunpan] [eyun]
// @author gxvv
// @license MIT
// @supportURL https://github.com/gxvv/ex-baiduyunpan/issues
// @date 01/01/2017
// @modified 20/08/2018
// @match *://pan.baidu.com/disk/home*
// @match *://yun.baidu.com/disk/home*
// @match *://pan.baidu.com/s/*
// @match *://yun.baidu.com/s/*
// @match *://pan.baidu.com/share/link?*
// @match *://yun.baidu.com/share/link?*
// @match *://eyun.baidu.com/s/*
// @match *://eyun.baidu.com/enterprise/share/link?*
// @run-at document-end
// @grant unsafeWindow
// @grant GM_addStyle
// @grant GM_info
// @require https://cdn.bootcss.com/babel-standalone/6.26.0/babel.min.js
// @require https://cdn.bootcss.com/clipboard.js/1.5.16/clipboard.min.js
// ==/UserScript==
/* jshint ignore:start */
var inline_src = (<><![CDATA[
/* jshint ignore:end */
/* jshint esnext: false */
/* jshint esversion: 6 */
define('ex-yunpan:pageInfo', () => {
const URL_HREF = location.href;
const MATCHS = {
'https?://(pan|yun).baidu.com/disk/home.*': 'pan',
'https?://(pan|yun).baidu.com/s/.*': 'share',
'https?://(pan|yun).baidu.com/share/link\?.*': 'share',
'https?://eyun.baidu.com/(s|enterprise)/.*': 'enterprise'
};
const PAGE_CONFIG = {
pan: {
prefix: 'function-widget-1:',
product: 'pan',
containers: ['.g-button[title="\u79bb\u7ebf\u4e0b\u8f7d"]'],
style: () => {}
},
share: {
prefix: 'function-widget-1:',
product: 'share',
containers: [
'div:not(.file-name)>div>.x-button-box>.g-
button[title^="\u4e0b\u8f7d"]',
'.module-share-top-bar .x-button-box>.g-
button[title="\u4e0b\u8f7d"]'
],
style: () => {
let style = `.KPDwCE .QxJxtg {z-index: 2;}
.module-share-header .slide-show-right {width:
auto;}
.ex-yunpan-dropdown-button.g-dropdown-
button.button-open .menu {z-index:41;}
.module-share-header .slide-show-header h2
{width:210px;}
.g-dropdown-button.ex-yunpan-dropdown-button
{margin: 0 5px!important;}`;
GM_addStyle(style);
}
},
enterprise: {
prefix: 'business-function:',
product: 'enterprise',
containers: ['div:not(.operate)>.button-box-container>.g-
button[title="\u4e0b\u8f7d"]'],
style: () => {
let style= `.ex-yunpan-dropdown-button .icon-
download{background-image: url(/box-static/business-function/infos/icons_z.png);}
.ex-yunpan-dropdown-button .g-button:hover
.icon-download{background-position: 0px -34px;}`;
GM_addStyle(style);
}
}
};
let currentPage = 'pan';
return ctx;
});
if (limitedIsRemoved) {
let tipConfig = {
mode: 'success',
msg: 'EX-baiduyunpan: 插件加载成功'
};
try {
await require('ex-yunpan:downloadBtnInit');
} catch (e) {
tipConfig = {
mode: 'caution',
msg: 'EX-baiduyunpan: 插件加载成功,按钮初始化失败',
autoClose: false,
hasClose: true
};
}
ctx.ui.tip(tipConfig);
} else {
if(document.querySelector('#share_nofound_des,#error-info') !==
null) return;
throw new Error('插件加载失败 core crack failed');
}
});
start(ctx);
},
enablePrd: ['pan', 'share', 'enterprise']
}, {
title: '复制链接',
click: async () => {
let result = await fetchDownLinks();
if (result.length === 0) return;
let {show} = require('ex-yunpan:clipboardDialog');
show(result);
},
enablePrd: ['pan', 'share', 'enterprise']
}, {
title: '复制压缩链接',
click: async () => {
let result = await fetchDownLinks('batch');
show(result);
},
enablePrd: ['pan', 'share', 'enterprise']
}, {
title: `<iframe src="https://ghbtns.com/github-btn.html?
user=gxvv&repo=ex-baiduyunpan&type=star&count=true"
frameborder="0" scrolling="0" style="margin-top:
6px;height: 20px;width: 170px;"></iframe>`,
enablePrd: ['pan', 'share', 'enterprise']
}
];
let exDlBtnConfig = {
type: 'dropdown',
title: 'EX-下载',
resize: true,
menu: menus.filter(menu =>
~menu.enablePrd.indexOf(currentProduct)),
icon: 'icon-download'
};
let selectors = pageInfo.containers.join();
let elements = [].slice.call(document.querySelectorAll(selectors) ||
[], 0);
elements.forEach(element => {
let exDlBtn = ctx.ui.button(exDlBtnConfig);
exDlBtn.dom.addClass('ex-yunpan-dropdown-
button').insertAfter(element);
exDlBtn.resizeButtonWidth();
});
pageInfo.style();
});
define('ex-yunpan:fetchDownLinks', () => {
let ctx = require('ex-yunpan:ctx');
let {prefix} = require('ex-yunpan:pageInfo');
let dServ = null;
if (selectedList.length === 0) {
ctx.ui.tip({mode: 'caution',
msg: 'EX-baiduyunpan: 您还没有选择下载的文件'});
return [];
}
let {pageInfo: {currentProduct = 'pan'} = {currentProduct: 'pan'}}
= ctx;
let foldersList = selectedList.filter(item => item.isdir === 1);
let filesList = selectedList.filter(item => item.isdir === 0);
ctx.ui.hideTip();
let failedRes = result.filter(res => res.errno !== 0);
if (failedRes.length > 0) {
try {
dServ.dialog.hide();
} catch (e) {/* do nothing */}
ctx.ui.tip({mode: 'caution',
msg: `EX-baiduyunpan: ${failedRes.length}个文件请求链
接失败`});
}
let dlinks = [];
return fetchDownLinks;
});
define('ex-yunpan:clipboardDialog', () => {
let ctx = require('ex-yunpan:ctx');
let show = list => {
let clipboard;
let maxrow = list.length > 10 ? 11 : list.length + 1;
let textareaHtml = `<textarea id="ExTextArea" rows="${maxrow}"
style="width: 100%;white-space: nowrap;resize:
none">${list.join('\n')}</textarea>`;
let dialog = ctx.ui.confirm({
title: '复制链接',
body: textareaHtml,
sureText: '复制',
onClose: () => {
if (clipboard && clipboard.destory) {
clipboard.destroy();
}
}
});
dialog.buttonIns[0].dom.attr({
'data-clipboard-action': 'copy',
'data-clipboard-target': '#ExTextArea'
}).addClass('ex-clip-btn').off();
clipboard = new Clipboard('.ex-clip-btn');
clipboard.on('success', e => {
ctx.ui.tip({mode: 'success',
msg: `EX-baiduyunpan: 复制${list.length}个链接`});
e.clearSelection();
dialog.hide();
clipboard.destroy();
}).on('error', e => {
ctx.ui.tip({mode: 'caution',
msg: 'EX-baiduyunpan: 复制失败,请手动复制'});
clipboard.destory();
});
};
return {
show
};
});
require('ex-yunpan:pluginInit').catch(ex => {
showError(ex);
});
})(unsafeWindow);
/* jshint ignore:start */
]]></>).toString();
var c = Babel.transform(inline_src, { presets: ["es2015", "es2016"] });
eval(c.code);
/* jshint ignore:end */