百度网盘直链下载助手
; ( function ( ) {
'use strict' ;
const version = '4.1.4' ;
const classMap = {
'bar-search' : 'OFaPaO' ,
'list-tools' : 'tcuLAu' ,
'header' : 'vyQHNyb'
} ;
const hostname = location. hostname;
const errorMsg = {
'dir' : '提示:不支持整个文件夹下载,可进入文件夹内获取文件链接下载!' ,
'unlogin' : '提示:登录百度网盘后才能使用此功能哦!' ,
'fail' : '提示:获取下载链接失败!请刷新网页后重试!' ,
'unselected' : '提示:请先选择要下载的文件!' ,
'morethan' : '提示:多个文件请点击【显示链接】!' ,
'toobig' : '提示:只支持300M以下的文件夹,若链接无法下载,请进入文件夹后勾选文件获取!' ,
'timeout' : '提示:页面过期,请刷新重试!' ,
'wrongcode' : '提示:获取验证码失败!' ,
'deleted' : '提示:文件不存在或已被百度和谐,无法下载!' ,
} ;
let defaultCode = 250528 ;
let secretCode = getValue ( 'secretCodeV' ) ? getValue ( 'secretCodeV' ) : defaultCode;
let ids = [ ] ;
let userAgent = '' ;
let userAgentDefault = navigator. userAgent;
let number = [ '' , '①' , '②' , '③' , '④' , '⑤' , '⑥' , '⑦' , '⑧' , '⑨' ] ;
let copyright = 'Powerd By 网盘直链下载助手 ,建议配合网盘 超级会员 使用' ;
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) ;
}
} ) ;
let ariaRPC = {
domain: getValue ( 'rpcDomain' ) ? getValue ( 'rpcDomain' ) : 'http://localhost' ,
port: getValue ( 'rpcPort' ) ? getValue ( 'rpcPort' ) : 6800 ,
token: getValue ( 'rpcToken' ) ? getValue ( 'rpcToken' ) : '' ,
dir: getValue ( 'rpcDir' ) ? getValue ( 'rpcDir' ) : 'D:/' ,
} ;
function clog ( c1, c2, c3) {
c1 = c1 ? c1 : '' ;
c2 = c2 ? c2 : '' ;
c3 = c3 ? c3 : '' ;
console. group ( '[百度网盘直链下载助手]' ) ;
console. log ( c1, c2, c3) ;
console. groupEnd ( ) ;
}
function getBDUSS ( ) {
let baiduyunPlugin_BDUSS = getStorage ( 'baiduyunPlugin_BDUSS' ) ? getStorage ( 'baiduyunPlugin_BDUSS' ) : '{"baiduyunPlugin_BDUSS":""}' ;
let BDUSS = JSON . parse ( baiduyunPlugin_BDUSS) . BDUSS ;
if ( ! BDUSS ) {
Swal. fire ( {
icon: 'error' ,
title: '提示' ,
html: 'Aria链接获取需要配合【网盘万能助手】使用 ' ,
footer: '【网盘万能助手】是增强扩展插件,安装后请刷新' ,
confirmButtonText: '安装'
} ) . then ( ( result) => {
if ( result. value) {
GM_openInTab ( 'https://www.baiduyun.wiki/zh-cn/assistant.html' , { active: true } ) ;
}
} ) ;
}
return BDUSS ;
}
function aria2c ( link, filename, ua) {
let BDUSS = getBDUSS ( ) ;
ua = ua || userAgent;
if ( BDUSS ) {
return encodeURIComponent ( `aria2c " ${ link} " --out " ${ filename} " --header "User-Agent: ${ ua} " --header "Cookie: BDUSS= ${ BDUSS } "` ) ;
} else {
return '请先安装网盘万能助手,安装后请重启浏览器!!!' ;
}
}
function replaceLink ( link) {
return link ? link. replace ( /&/g , '&' ) : '' ;
}
function detectPage ( ) {
let regx = /[\/].+[\/]/g ;
let page = location. pathname. match ( regx) ;
return page[ 0 ] . replace ( /\//g , '' ) ;
}
function getCookie ( e) {
let o, t;
let n = document, c = decodeURI;
return n. cookie. length > 0 && ( o = n. cookie. indexOf ( e + "=" ) , - 1 != o) ? ( o = o + e. length + 1 , t = n. cookie. indexOf ( ";" , o) , - 1 == t && ( t = n. cookie. length) , c ( n. cookie. substring ( o, t) ) ) : "" ;
}
function setCookie ( key, value, t) {
let oDate = new Date ( ) ;
oDate. setTime ( oDate. getTime ( ) + t * 60 * 1000 ) ;
document. cookie = key + '=' + value + ';expires=' + oDate. toGMTString ( ) ;
}
function removeCookie ( key) {
setCookie ( key, '' , - 1 ) ;
}
function getValue ( name) {
return GM_getValue ( name) ;
}
function setValue ( name, value) {
GM_setValue ( name, value) ;
}
function getStorage ( key) {
return localStorage. getItem ( key) ;
}
function setStorage ( key, value) {
return localStorage. setItem ( key, value) ;
}
function getLogID ( ) {
let name = "BAIDUID" ;
let u = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/~!@#¥%……&" ;
let d = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g ;
let f = String. fromCharCode;
function l ( e) {
if ( e. length < 2 ) {
let n = e. charCodeAt ( 0 ) ;
return 128 > n ? e : 2048 > n ? f ( 192 | n >>> 6 ) + f ( 128 | 63 & n) : f ( 224 | n >>> 12 & 15 ) + f ( 128 | n >>> 6 & 63 ) + f ( 128 | 63 & n) ;
}
let n = 65536 + 1024 * ( e. charCodeAt ( 0 ) - 55296 ) + ( e. charCodeAt ( 1 ) - 56320 ) ;
return f ( 240 | n >>> 18 & 7 ) + f ( 128 | n >>> 12 & 63 ) + f ( 128 | n >>> 6 & 63 ) + f ( 128 | 63 & n) ;
}
function g ( e) {
return ( e + "" + Math. random ( ) ) . replace ( d, l) ;
}
function m ( e) {
let n = [ 0 , 2 , 1 ] [ e. length % 3 ] ;
let t = e. charCodeAt ( 0 ) << 16 | ( e. length > 1 ? e. charCodeAt ( 1 ) : 0 ) << 8 | ( e. length > 2 ? e. charCodeAt ( 2 ) : 0 ) ;
let o = [ u. charAt ( t >>> 18 ) , u. charAt ( t >>> 12 & 63 ) , n >= 2 ? "=" : u. charAt ( t >>> 6 & 63 ) , n >= 1 ? "=" : u. charAt ( 63 & t) ] ;
return o. join ( "" ) ;
}
function h ( e) {
return e. replace ( /[\s\S]{1,3}/g , m) ;
}
function p ( ) {
return h ( g ( ( new Date ( ) ) . getTime ( ) ) ) ;
}
function w ( e, n) {
return n ? p ( String ( e) ) . replace ( /[+\/]/g , function ( e) {
return "+" == e ? "-" : "_" ;
} ) . replace ( /=/g , "" ) : p ( String ( e) ) ;
}
return w ( getCookie ( name) ) ;
}
function Dialog ( ) {
let linkList = [ ] ;
let showParams;
let dialog, shadow;
function createDialog ( ) {
let screenWidth = document. body. clientWidth;
let dialogLeft = screenWidth > 800 ? ( screenWidth - 800 ) / 2 : 0 ;
let $dialog_div = $ ( '+ dialogLeft + 'px; right: auto; display: hidden; visibility: visible; z-index: 52;">
' ) ;
let $dialog_header = $ ( '' ) ;
let $dialog_control = $ ( '×
' ) ;
let $dialog_body = $ ( '
' ) ;
let $dialog_tip = $ ( '' ) ;
$dialog_div. append ( $dialog_header. append ( $dialog_control) ) . append ( $dialog_body) ;
let $dialog_button = $ ( '
' ) ;
let $dialog_button_div = $ ( '
' ) ;
let $dialog_copy_button = $ ( '复制全部默认链接 ' ) ;
let $dialog_edit_button = $ ( '编辑 ' ) ;
let $dialog_exit_button = $ ( '退出 ' ) ;
$dialog_button_div. append ( $dialog_copy_button) . append ( $dialog_edit_button) . append ( $dialog_exit_button) ;
$dialog_button. append ( $dialog_button_div) ;
$dialog_div. append ( $dialog_button) ;
$dialog_copy_button. click ( function ( ) {
let content = '' ;
if ( showParams. type == 'batch' ) {
$. each ( linkList, function ( index, element) {
if ( index == linkList. length - 1 )
content += element. downloadlink[ 0 ] ;
else
content += element. downloadlink[ 0 ] + '\r\n' ;
} ) ;
}
if ( showParams. type == 'batchAria' ) {
$. each ( linkList, function ( index, element) {
if ( index == linkList. length - 1 )
content += decodeURIComponent ( aria2c ( element. downloadlink[ 0 ] , element. filename, userAgentDefault) ) ;
else
content += decodeURIComponent ( aria2c ( element. downloadlink[ 0 ] , element. filename, userAgentDefault) + '\r\n' ) ;
} ) ;
}
if ( showParams. type == 'rpc' ) {
$. each ( linkList, function ( index, element) {
if ( element. downloadlink == 'error' )
return ;
if ( index == linkList. length - 1 )
content += element. downloadlink;
else
content += element. downloadlink + '\r\n' ;
} ) ;
}
if ( showParams. type == 'shareLink' ) {
$. each ( linkList, function ( index, element) {
if ( element. dlink == 'error' )
return ;
if ( index == linkList. length - 1 )
content += element. dlink;
else
content += element. dlink + '\r\n' ;
} ) ;
}
if ( showParams. type == 'shareAriaLink' ) {
$. each ( linkList, function ( index, element) {
if ( element. dlink == 'error' )
return ;
if ( index == linkList. length - 1 )
content += decodeURIComponent ( aria2c ( element. dlink, element. server_filename) ) ;
else
content += decodeURIComponent ( aria2c ( element. dlink, element. server_filename) + '\r\n' ) ;
} ) ;
}
GM_setClipboard ( content, 'text' ) ;
if ( content != '' ) {
Toast. fire ( {
icon: 'success' ,
text: '已将链接复制到剪贴板!'
} ) ;
} else {
Toast. fire ( {
icon: 'error' ,
text: '复制失败,请手动复制!'
} ) ;
}
} ) ;
$dialog_edit_button. click ( function ( ) {
let $dialog_textarea = $ ( 'div.dialog-body textarea[name=dialog-textarea]' , dialog) ;
let $dialog_item = $ ( 'div.dialog-body div' , dialog) ;
$dialog_item. hide ( ) ;
$dialog_copy_button. hide ( ) ;
$dialog_edit_button. hide ( ) ;
$dialog_textarea. show ( ) ;
$dialog_radio_div. show ( ) ;
$dialog_exit_button. show ( ) ;
} ) ;
$dialog_exit_button. click ( function ( ) {
let $dialog_textarea = $ ( 'div.dialog-body textarea[name=dialog-textarea]' , dialog) ;
let $dialog_item = $ ( 'div.dialog-body div' , dialog) ;
$dialog_textarea. hide ( ) ;
$dialog_radio_div. hide ( ) ;
$dialog_item. show ( ) ;
$dialog_exit_button. hide ( ) ;
$dialog_copy_button. show ( ) ;
$dialog_edit_button. show ( ) ;
} ) ;
$dialog_div. append ( $dialog_tip) ;
$ ( 'body' ) . append ( $dialog_div) ;
$dialog_control. click ( dialogControl) ;
return $dialog_div;
}
function createShadow ( ) {
let $shadow = $ ( '
' ) ;
$ ( 'body' ) . append ( $shadow) ;
return $shadow;
}
this . open = function ( params) {
showParams = params;
linkList = [ ] ;
if ( params. type == 'link' ) {
linkList = params. list. urls;
$ ( 'div.dialog-header h3 span.dialog-title' , dialog) . text ( params. title + ":" + params. list. filename) ;
$. each ( params. list. urls, function ( index, element) {
element. url = replaceLink ( element. url) ;
let $div = $ ( '' ) ;
$ ( 'div.dialog-body' , dialog) . append ( $div) ;
} ) ;
}
if ( params. type == 'batch' || params. type == 'batchAria' || params. type == 'batchAriaRPC' ) {
linkList = params. list;
$ ( 'div.dialog-header h3 span.dialog-title' , dialog) . text ( params. title) ;
$. each ( params. list, function ( index, element) {
let $div = $ ( '+ element. filename + '">' + element. filename + '
: ' ) ;
if ( params. type == 'batch' ) {
$. each ( element. downloadlink, function ( i, e) {
if ( i === 0 ) {
$div. append ( $ ( '+ e + '" data-link=' + e + '>默认链接' ) ) ;
} else {
if ( getValue ( 'SETTING_B' ) )
$div. append ( $ ( '+ e + '" data-link=' + e + '>备用链接' + number[ i] + '' ) ) ;
}
} ) ;
}
if ( params. type == 'batchAria' ) {
$. each ( element. downloadlink, function ( i, e) {
let link = aria2c ( e, element. filename, userAgentDefault) ;
if ( i === 0 ) {
$div. append ( $ ( '默认链接 ' ) ) ;
} else {
if ( getValue ( 'SETTING_B' ) )
$div. append ( $ ( '备用链接' + number[ i] + '' ) ) ;
}
} ) ;
}
if ( params. type == 'batchAriaRPC' ) {
$. each ( element. downloadlink, function ( i, e) {
if ( i === 0 ) {
$div. append ( $ ( '+ e + '" data-filename="' + element. filename + '">发送默认' ) ) ;
} else {
if ( getValue ( 'SETTING_B' ) )
$div. append ( $ ( '+ e + '" data-filename="' + element. filename + '">发送备用' + number[ i] + '' ) ) ;
}
} ) ;
}
$ ( 'div.dialog-body' , dialog) . append ( $div) ;
} ) ;
}
if ( params. type == 'shareLink' ) {
linkList = params. list;
$ ( 'div.dialog-header h3 span.dialog-title' , dialog) . text ( params. title) ;
$. each ( params. list, function ( index, element) {
element. dlink = replaceLink ( element. dlink) ;
if ( element. isdir == 1 ) return ;
let $div = $ ( '' ) ;
$ ( 'div.dialog-body' , dialog) . append ( $div) ;
} ) ;
}
if ( params. type == 'rpcLink' ) {
linkList = params. list;
$ ( 'div.dialog-header h3 span.dialog-title' , dialog) . text ( params. title) ;
$. each ( params. list, function ( index, element) {
element. dlink = replaceLink ( element. dlink) ;
if ( element. isdir == 1 ) return ;
let $div = $ ( '+ element. server_filename + '">' + element. server_filename + '
: + element. dlink + '" data-filename="' + element. server_filename + '">点击发送到Aria ' ) ;
$ ( 'div.dialog-body' , dialog) . append ( $div) ;
} ) ;
}
if ( params. type == 'shareAriaLink' ) {
linkList = params. list;
$ ( 'div.dialog-header h3 span.dialog-title' , dialog) . text ( params. title) ;
$. each ( params. list, function ( index, element) {
if ( element. isdir == 1 ) return ;
let link = decodeURIComponent ( aria2c ( element. dlink, element. server_filename) ) ;
let $div = $ ( '+ element. server_filename + '">' + element. server_filename + '
: ' + link + ' ' ) ;
$ ( 'div.dialog-body' , dialog) . append ( $div) ;
} ) ;
}
if ( params. tip) {
$ ( 'div.dialog-tip p' , dialog) . html ( params. tip) ;
}
if ( params. showcopy) {
$ ( 'div.dialog-button' , dialog) . show ( ) ;
$ ( 'div.dialog-button button#dialog-copy-button' , dialog) . show ( ) ;
}
shadow. show ( ) ;
dialog. show ( ) ;
} ;
this . close = function ( ) {
dialogControl ( ) ;
} ;
function dialogControl ( ) {
$ ( 'div.dialog-body' , dialog) . children ( ) . remove ( ) ;
$ ( 'div.dialog-header h3 span.dialog-title' , dialog) . text ( '' ) ;
$ ( 'div.dialog-tip p' , dialog) . text ( '' ) ;
$ ( 'div.dialog-button' , dialog) . hide ( ) ;
$ ( 'div.dialog-radio input[type=radio][name=showmode][value=multi]' , dialog) . prop ( 'checked' , true ) ;
$ ( 'div.dialog-radio' , dialog) . hide ( ) ;
$ ( 'div.dialog-button button#dialog-copy-button' , dialog) . hide ( ) ;
$ ( 'div.dialog-button button#dialog-edit-button' , dialog) . hide ( ) ;
$ ( 'div.dialog-button button#dialog-exit-button' , dialog) . hide ( ) ;
dialog. hide ( ) ;
shadow. hide ( ) ;
}
dialog = createDialog ( ) ;
shadow = createShadow ( ) ;
}
function VCodeDialog ( refreshVCode, confirmClick) {
let dialog, shadow;
function createDialog ( ) {
let screenWidth = document. body. clientWidth;
let dialogLeft = screenWidth > 520 ? ( screenWidth - 520 ) / 2 : 0 ;
let $dialog_div = $ ( '+ dialogLeft + 'px;right:auto;display:none;visibility:visible;z-index:52">
' ) ;
let $dialog_header = $ ( '' ) ;
let $dialog_control = $ ( 'x
' ) ;
let $dialog_body = $ ( '
' ) ;
let $dialog_body_div = $ ( '
' ) ;
let $dialog_body_download_verify = $ ( '
' ) ;
let $dialog_verify_body = $ ( '请输入验证码:
' ) ;
let $dialog_input = $ ( ' ' ) ;
let $dialog_img = $ ( ' ' ) ;
let $dialog_refresh = $ ( '换一张 ' ) ;
let $dialog_err = $ ( '
' ) ;
let $dialog_footer = $ ( '' ) ;
let $dialog_confirm_button = $ ( '确定 ' ) ;
let $dialog_cancel_button = $ ( '取消 ' ) ;
$dialog_header. append ( $dialog_control) ;
$dialog_verify_body. append ( $dialog_input) . append ( $dialog_img) . append ( $dialog_refresh) ;
$dialog_body_download_verify. append ( $dialog_verify_body) . append ( $dialog_err) ;
$dialog_body_div. append ( $dialog_body_download_verify) ;
$dialog_body. append ( $dialog_body_div) ;
$dialog_footer. append ( $dialog_confirm_button) . append ( $dialog_cancel_button) ;
$dialog_div. append ( $dialog_header) . append ( $dialog_body) . append ( $dialog_footer) ;
$ ( 'body' ) . append ( $dialog_div) ;
$dialog_control. click ( dialogControl) ;
$dialog_img. click ( refreshVCode) ;
$dialog_refresh. click ( refreshVCode) ;
$dialog_input. keypress ( function ( event) {
if ( event. which == 13 )
confirmClick ( ) ;
} ) ;
$dialog_confirm_button. click ( confirmClick) ;
$dialog_cancel_button. click ( dialogControl) ;
$dialog_input. click ( function ( ) {
$ ( '#dialog-err' ) . text ( '' ) ;
} ) ;
return $dialog_div;
}
this . open = function ( vcode) {
if ( vcode)
$ ( '#dialog-img' ) . attr ( 'src' , vcode. img) ;
dialog. show ( ) ;
shadow. show ( ) ;
} ;
this . close = function ( ) {
dialogControl ( ) ;
} ;
dialog = createDialog ( ) ;
shadow = $ ( 'div.dialog-shadow' ) ;
function dialogControl ( ) {
$ ( '#dialog-img' , dialog) . attr ( 'src' , '' ) ;
$ ( '#dialog-err' ) . text ( '' ) ;
dialog. hide ( ) ;
shadow. hide ( ) ;
}
}
function PanHelper ( ) {
let yunData, sign, timestamp, bdstoken, logid, fid_list;
let fileList = [ ] , selectFileList = [ ] , batchLinkList = [ ] , batchLinkListAll = [ ] , linkList = [ ] ;
let dialog, searchKey;
let panAPIUrl = location. protocol + "//" + location. host + "/api/" ;
let restAPIUrl = location. protocol + "//pcs.baidu.com/rest/2.0/pcs/" ;
let clientAPIUrl = location. protocol + "//d.pcs.baidu.com/rest/2.0/pcs/" ;
this . init = function ( ) {
yunData = unsafeWindow. yunData;
clog ( '初始化信息:' , yunData) ;
if ( yunData === undefined) {
clog ( '页面未正常加载,或者百度已经更新!' ) ;
return false ;
}
initVar ( ) ;
registerEventListener ( ) ;
addButton ( ) ;
createIframe ( ) ;
dialog = new Dialog ( { addCopy: true } ) ;
clog ( '下载助手加载成功!当前版本:' , version) ;
} ;
function getSelectedFile ( ) {
return require ( "disk-system:widget/pageModule/list/listInit.js" ) . getCheckedItems ( ) ;
}
function initVar ( ) {
sign = getSign ( ) ;
timestamp = yunData. timestamp;
bdstoken = yunData. MYBDSTOKEN ;
logid = getLogID ( ) ;
}
function registerEventListener ( ) {
registerDownload ( ) ;
}
function registerDownload ( ) {
$ ( document) . on ( 'click' , '.api-link' , function ( e) {
e. preventDefault ( ) ;
if ( e. target. dataset. link) {
execDownload ( e. target. dataset. link) ;
}
} ) ;
$ ( document) . on ( 'click' , '.aria-rpc' , function ( e) {
let link = e. target. dataset. link;
let filename = e. target. dataset. filename;
let headers = { } ;
if ( ! isSuperVIP ( ) ) {
headers = {
"User-Agent" : userAgent
} ;
}
GM_xmlhttpRequest ( {
method: "HEAD" ,
headers: headers,
url: e. target. dataset. link,
onload: function ( res) {
let finalUrl = res. finalUrl;
if ( finalUrl) {
let url = ariaRPC. domain + ":" + ariaRPC. port + '/jsonrpc' ;
let json_rpc = {
id: new Date ( ) . getTime ( ) ,
jsonrpc: '2.0' ,
method: 'aria2.addUri' ,
params: [
"token:" + ariaRPC. token,
[ finalUrl] ,
{
dir: ariaRPC. dir,
out: filename,
header: isSuperVIP ( ) ? [ 'User-Agent:' + userAgentDefault, 'Cookie: BDUSS=' + getBDUSS ( ) ] : [ 'User-Agent:' + userAgent, 'Cookie: BDUSS=' + getBDUSS ( ) ]
}
]
} ;
GM_xmlhttpRequest ( {
method: "POST" ,
headers: {
"User-Agent" : userAgent
} ,
url: url,
responseType: 'json' ,
timeout: 3000 ,
data: JSON . stringify ( json_rpc) ,
onload: function ( response) {
if ( response. response. result) {
Toast. fire ( {
icon: 'success' ,
title: '任务已发送至RPC下载器'
} ) ;
} else {
Toast. fire ( {
icon: 'error' ,
title: response. response. message
} ) ;
}
} ,
ontimeout: function ( ) {
Toast. fire ( {
icon: 'error' ,
title: '无法连接到RPC服务,请检查RPC配置'
} ) ;
}
} ) ;
}
} ,
} ) ;
} ) ;
}
function registerShareClick ( ) {
$ ( document) . on ( 'click' , '[title="分享"]' , function ( ) {
let inv = setInterval ( function ( ) {
if ( $ ( '#share-method-public' ) . length === 0 ) {
$ ( ".share-method-line" ) . parent ( ) . append ( '公开分享 任何人访问链接即可查看,下载!
' ) ;
} else {
clearInterval ( inv) ;
$ ( document) . off ( 'click' , '[title="分享"]' ) ;
}
} , 100 ) ;
} ) ;
}
function addButton ( ) {
$ ( 'div.' + classMap[ 'bar-search' ] ) . css ( 'width' , '18%' ) ;
let $dropdownbutton = $ ( ' ' ) ;
let $dropdownbutton_a = $ ( '下载助手 ' ) ;
let $dropdownbutton_span = $ ( '' ) ;
let $directbutton = $ ( '' ) ;
let $directbutton_span = $ ( ' ' ) ;
let $directbutton_a = $ ( '直链下载 ' ) ;
let $directbutton_menu = $ ( '' ) ;
let $directbutton_batchhttplink_button = $ ( '' ) ;
$directbutton_menu. append ( $directbutton_batchhttplink_button) ;
$directbutton. append ( $directbutton_span. append ( $directbutton_a) . append ( $directbutton_menu) ) ;
$directbutton. hover ( function ( ) {
$directbutton_span. toggleClass ( 'button-open' ) ;
} ) ;
$directbutton_batchhttplink_button. click ( batchClick) ;
let $ariadirectbutton = $ ( '' ) ;
let $ariadirectbutton_span = $ ( ' ' ) ;
let $ariadirectbutton_a = $ ( 'Aria下载 ' ) ;
let $ariadirectbutton_menu = $ ( '' ) ;
let $ariadirectbutton_batchhttplink_button = $ ( '' ) ;
$ariadirectbutton_menu. append ( $ariadirectbutton_batchhttplink_button) ;
$ariadirectbutton. append ( $ariadirectbutton_span. append ( $ariadirectbutton_a) . append ( $ariadirectbutton_menu) ) ;
$ariadirectbutton. hover ( function ( ) {
$ariadirectbutton_span. toggleClass ( 'button-open' ) ;
} ) ;
$ariadirectbutton_batchhttplink_button. click ( batchClick) ;
let $ariarpcbutton = $ ( '' ) ;
let $ariarpcbutton_span = $ ( ' ' ) ;
let $ariarpcbutton_a = $ ( 'RPC下载 ' ) ;
let $ariarpcbutton_menu = $ ( '' ) ;
let $ariarpcbutton_batchhttplink_button = $ ( '' ) ;
let $ariarpcbutton_setting_button = $ ( '' ) ;
$ariarpcbutton_menu. append ( $ariarpcbutton_batchhttplink_button) . append ( $ariarpcbutton_setting_button) ;
$ariarpcbutton. append ( $ariarpcbutton_span. append ( $ariarpcbutton_a) . append ( $ariarpcbutton_menu) ) ;
$ariarpcbutton. hover ( function ( ) {
$ariarpcbutton_span. toggleClass ( 'button-open' ) ;
} ) ;
$ariarpcbutton_batchhttplink_button. click ( batchClick) ;
$ariarpcbutton_setting_button. click ( rpcSetting) ;
let $apibutton = $ ( '' ) ;
let $apibutton_span = $ ( ' ' ) ;
let $apibutton_a = $ ( 'API下载 ' ) ;
let $apibutton_menu = $ ( '' ) ;
let $apibutton_download_button = $ ( '' ) ;
let $apibutton_batchhttplink_button = $ ( '' ) ;
let $setting_button = $ ( '' ) ;
let $default_setting = $ ( '' ) ;
$apibutton_menu. append ( $apibutton_download_button) . append ( $apibutton_batchhttplink_button) / * . append ( $setting_button) . append ( $default_setting) * / ;
let $sharebutton = $ ( '' ) ;
let $versionButton = $ ( ' + version + '' ) ;
$apibutton. append ( $apibutton_span. append ( $apibutton_a) . append ( $apibutton_menu) ) ;
$apibutton. hover ( function ( ) {
$apibutton_span. toggleClass ( 'button-open' ) ;
} ) ;
$apibutton_download_button. click ( downloadClick) ;
$apibutton_batchhttplink_button. click ( batchClick) ;
$setting_button. click ( setSecretCode) ;
$default_setting. click ( defaultSetting) ;
$versionButton. click ( versionButtonClick) ;
$sharebutton. click ( shareButtonClick) ;
$dropdownbutton_span. append ( $apibutton) . append ( $ariadirectbutton) . append ( $ariarpcbutton) . append ( $sharebutton) . append ( $versionButton) ;
$dropdownbutton. append ( $dropdownbutton_a) . append ( $dropdownbutton_span) ;
$dropdownbutton. hover ( function ( ) {
$dropdownbutton. toggleClass ( 'button-open' ) ;
} ) ;
$ ( '.' + classMap[ 'list-tools' ] ) . append ( $dropdownbutton) ;
$ ( '.' + classMap[ 'list-tools' ] ) . css ( 'height' , '40px' ) ;
}
function rpcSetting ( ) {
let dom = '' ;
dom += '主机: + ariaRPC. domain + '" class="swal2-input" placeholder="http://localhost">
' ;
dom += '端口: + ariaRPC. port + '" class="swal2-input" placeholder="6800">
' ;
dom += '密钥: + ariaRPC. token + '" class="swal2-input" placeholder="没有留空">
' ;
dom += '下载路径: + ariaRPC. dir + '" class="swal2-input" placeholder="默认为D:\">
' ;
dom = '' + dom + '
' ;
let $dom = $ ( dom) ;
Swal. fire ( {
title: 'RPC配置' ,
allowOutsideClick: false ,
html: $dom[ 0 ] ,
showCancelButton: true ,
confirmButtonText: '保存' ,
cancelButtonText: '取消'
}
) . then ( ( result) => {
if ( result. value) {
setValue ( 'rpcDomain' , $ ( '#rpcDomain' ) . val ( ) ? $ ( '#rpcDomain' ) . val ( ) : ariaRPC. domain) ;
setValue ( 'rpcPort' , $ ( '#rpcPort' ) . val ( ) ? $ ( '#rpcPort' ) . val ( ) : ariaRPC. port) ;
setValue ( 'rpcToken' , $ ( '#rpcToken' ) . val ( ) ) ;
setValue ( 'rpcDir' , $ ( '#rpcDir' ) . val ( ) ? $ ( '#rpcDir' ) . val ( ) : ariaRPC. dir) ;
history. go ( 0 ) ;
}
} ) ;
}
function setSecretCode ( ) {
Swal. fire ( {
title: '请输入神秘代码' ,
input: 'text' ,
inputValue: secretCode,
showCancelButton: true ,
confirmButtonText: '确定' ,
cancelButtonText: '取消' ,
inputValidator: ( value) => {
if ( value. length != 6 ) {
return '请输入正确的神秘代码' ;
}
}
} ) . then ( ( result) => {
setValue ( 'secretCodeV' , result. value) ;
Toast. fire ( {
icon: 'success' ,
text: '神秘代码执行成功,3s后将自动刷新!'
} ) . then ( ( ) => {
history. go ( 0 ) ;
} ) ;
} ) ;
}
function defaultSetting ( ) {
setValue ( 'secretCodeV' , defaultCode) ;
Toast. fire ( {
text: '恢复默认成功,3s后将自动刷新' ,
icon: 'success'
} ) . then ( ( ) => {
history. go ( 0 ) ;
} ) ;
}
function isSuperVIP ( ) {
return yunData. ISSVIP === 1 ;
}
function versionButtonClick ( ) {
let url = 'https://www.baiduyun.wiki' ;
GM_openInTab ( url, { active: true } ) ;
}
function downloadClick ( event) {
selectFileList = getSelectedFile ( ) ;
clog ( '选中文件列表:' , selectFileList) ;
let id = event. target. id;
let downloadLink;
if ( id == 'download-direct' ) {
let downloadType;
if ( selectFileList. length === 0 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. unselected
} ) ;
return ;
}
if ( selectFileList. length == 1 ) {
selectFileList[ 0 ] . isdir === 1 ? downloadType = 'batch' : downloadType = 'dlink' ;
}
if ( selectFileList. length > 1 ) {
downloadType = 'batch' ;
}
fid_list = getFidList ( selectFileList) ;
let result = getDownloadLinkWithPanAPI ( downloadType) ;
if ( result. errno === 0 ) {
if ( downloadType == 'dlink' )
downloadLink = result. dlink[ 0 ] . dlink;
else if ( downloadType == 'batch' ) {
downloadLink = result. dlink;
if ( selectFileList. length === 1 )
downloadLink = downloadLink + '&zipname=' + encodeURIComponent ( selectFileList[ 0 ] . server_filename) + '.zip' ;
} else {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. fail
} ) ;
return ;
}
} else if ( result. errno == - 1 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. deleted
} ) ;
return ;
} else if ( result. errno == 112 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. timeout
} ) ;
return ;
} else {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. fail
} ) ;
return ;
}
} else {
if ( selectFileList. length === 0 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. unselected
} ) ;
return ;
} else if ( selectFileList. length > 1 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. morethan
} ) ;
return ;
} else {
if ( selectFileList[ 0 ] . isdir == 1 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. dir
} ) ;
return ;
}
}
if ( id == 'download-api' ) {
downloadLink = getDownloadLinkWithRESTAPIBaidu ( selectFileList[ 0 ] . path) ;
}
}
execDownload ( downloadLink) ;
}
function linkClick ( event) {
selectFileList = getSelectedFile ( ) ;
clog ( '选中文件列表:' , selectFileList) ;
let id = event. target. id;
let linkList, tip;
if ( id. indexOf ( 'direct' ) != - 1 ) {
let downloadType;
let downloadLink;
if ( selectFileList. length === 0 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. unselected
} ) ;
return ;
} else if ( selectFileList. length == 1 ) {
if ( selectFileList[ 0 ] . isdir === 1 )
downloadType = 'batch' ;
else if ( selectFileList[ 0 ] . isdir === 0 )
downloadType = 'dlink' ;
} else if ( selectFileList. length > 1 ) {
downloadType = 'batch' ;
}
fid_list = getFidList ( selectFileList) ;
let result = getDownloadLinkWithPanAPI ( downloadType) ;
if ( result. errno === 0 ) {
if ( downloadType == 'dlink' )
downloadLink = result. dlink[ 0 ] . dlink;
else if ( downloadType == 'batch' ) {
clog ( '选中文件列表:' , selectFileList) ;
downloadLink = result. dlink;
if ( selectFileList. length === 1 )
downloadLink = downloadLink + '&zipname=' + encodeURIComponent ( selectFileList[ 0 ] . server_filename) + '.zip' ;
} else {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. fail
} ) ;
return ;
}
} else if ( result. errno == - 1 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. deleted
} ) ;
return ;
} else if ( result. errno == 112 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. timeout
} ) ;
return ;
} else {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. fail
} ) ;
return ;
}
let httplink = downloadLink. replace ( /^([A-Za-z]+):/ , 'http:' ) ;
let httpslink = downloadLink. replace ( /^([A-Za-z]+):/ , 'https:' ) ;
let filename = '' ;
$. each ( selectFileList, function ( index, element) {
if ( selectFileList. length == 1 )
filename = element. server_filename;
else {
if ( index == 0 )
filename = element. server_filename;
else
filename = filename + ',' + element. server_filename;
}
} ) ;
linkList = {
filename: filename,
urls: [
{ url: httplink, rank: 1 } ,
{ url: httpslink, rank: 2 }
]
} ;
tip = '显示模拟百度网盘网页获取的链接,可以使用右键迅雷或IDM下载,多文件打包(限300k)下载的链接可以直接复制使用' ;
dialog. open ( { title: '下载链接' , type: 'link' , list: linkList, tip: tip} ) ;
} else {
if ( selectFileList. length === 0 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. unselected
} ) ;
return ;
} else if ( selectFileList. length > 1 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. morethan
} ) ;
return ;
} else {
if ( selectFileList[ 0 ] . isdir == 1 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. dir
} ) ;
return ;
}
}
if ( id. indexOf ( 'api' ) != - 1 ) {
let downloadLink = getDownloadLinkWithRESTAPIBaidu ( selectFileList[ 0 ] . path) ;
let httplink = downloadLink. replace ( /^([A-Za-z]+):/ , 'http:' ) ;
let httpslink = downloadLink. replace ( /^([A-Za-z]+):/ , 'https:' ) ;
linkList = {
filename: selectFileList[ 0 ] . server_filename,
urls: [
{ url: httplink, rank: 1 } ,
{ url: httpslink, rank: 2 }
]
} ;
tip = '显示模拟APP获取的链接(使用百度云ID),可以右键使用迅雷或IDM下载,直接复制链接无效' ;
dialog. open ( { title: '下载链接' , type: 'link' , list: linkList, tip: tip} ) ;
}
}
}
function batchClick ( event) {
selectFileList = getSelectedFile ( ) ;
clog ( '选中文件列表:' , selectFileList) ;
if ( selectFileList. length === 0 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. unselected
} ) ;
return ;
}
let id = event. target. id;
let linkType, tip;
linkType = id. indexOf ( 'https' ) == - 1 ? ( id. indexOf ( 'http' ) == - 1 ? location. protocol + ':' : 'http:' ) : 'https:' ;
batchLinkList = [ ] ;
batchLinkListAll = [ ] ;
if ( id. indexOf ( 'direct' ) > 0 ) {
batchLinkList = getDirectBatchLink ( linkType) ;
let tip = '点击链接直接下载,请先升级 [网盘万能助手] 至 v2.3.1 ,本链接仅支持小文件下载(<300M)' ;
if ( batchLinkList. length === 0 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. unselected
} ) ;
return ;
}
dialog. open ( { title: '直链下载' , type: 'batch' , list: batchLinkList, tip: tip, showcopy: false } ) ;
}
if ( id. indexOf ( 'aria' ) > 0 ) {
batchLinkList = getAPIBatchLink ( linkType) ;
tip = '请先安装 网盘万能助手 请将链接复制到支持Aria的下载器中, 推荐使用 XDown ' ;
if ( batchLinkList. length === 0 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. unselected
} ) ;
return ;
}
dialog. open ( { title: 'Aria链接' , type: 'batchAria' , list: batchLinkList, tip: tip, showcopy: true } ) ;
}
if ( id. indexOf ( 'rpc' ) > 0 ) {
batchLinkList = getAPIBatchLink ( linkType) ;
tip = '点击按钮发送链接至Aria下载器中详细说明 ,需配合最新版 [网盘万能助手] ,支持本地和远程下载,此功能建议配合百度会员使用' ;
if ( batchLinkList. length === 0 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. unselected
} ) ;
return ;
}
dialog. open ( { title: 'Aria RPC' , type: 'batchAriaRPC' , list: batchLinkList, tip: tip, showcopy: false } ) ;
}
if ( id. indexOf ( 'api' ) != - 1 ) {
batchLinkList = getAPIBatchLink ( linkType) ;
tip = '请先安装 网盘万能助手 v2.3.1 后点击链接下载,若下载失败,请开启 备用链接 ' ;
if ( batchLinkList. length === 0 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. unselected
} ) ;
return ;
}
dialog. open ( { title: 'API下载链接' , type: 'batch' , list: batchLinkList, tip: tip} ) ;
}
}
function getDirectBatchLink ( linkType) {
let list = [ ] ;
$. each ( selectFileList, function ( index, element) {
let downloadType, downloadLink, result;
if ( element. isdir == 0 )
downloadType = 'dlink' ;
else
downloadType = 'batch' ;
fid_list = getFidList ( [ element] ) ;
result = getDownloadLinkWithPanAPI ( downloadType) ;
if ( result. errno == 0 ) {
if ( downloadType == 'dlink' )
downloadLink = result. dlink[ 0 ] . dlink;
else if ( downloadType == 'batch' )
downloadLink = result. dlink;
downloadLink = downloadLink. replace ( /^([A-Za-z]+):/ , linkType) ;
} else {
downloadLink = 'error' ;
}
list. push ( { filename: element. server_filename, downloadlink: downloadLink} ) ;
} ) ;
return list;
}
function getAPIBatchLink ( linkType) {
let list = [ ] ;
$. each ( selectFileList, function ( index, element) {
if ( element. isdir == 1 )
return ;
let downloadLink;
downloadLink = getDownloadById ( element. path) ;
list. push ( {
filename: element. server_filename,
downloadlink: downloadLink,
} ) ;
} ) ;
return list;
}
function getSign ( ) {
let signFnc;
try {
signFnc = new Function ( "return " + yunData. sign2) ( ) ;
} catch ( e ) {
throw new Error ( e. message) ;
}
return btoa ( signFnc ( yunData. sign5, yunData. sign1) ) ;
}
function getFidList ( list) {
let fidlist = null ;
if ( list. length === 0 )
return null ;
let fileidlist = [ ] ;
$. each ( list, function ( index, element) {
fileidlist. push ( element. fs_id) ;
} ) ;
fidlist = '[' + fileidlist + ']' ;
return fidlist;
}
function shareButtonClick ( ) {
selectFileList = getSelectedFile ( ) ;
let path = [ ] ;
if ( selectFileList. length === 0 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. unselected
} ) ;
return ;
}
$. each ( selectFileList, function ( i, val) {
path. push ( val[ 'path' ] ) ;
} ) ;
let shareAPIUrl = "https://pan.baidu.com/share/set?channel=chunlei&clienttype=0&web=1&channel=chunlei&web=1&app_id=250528&bdstoken=" + bdstoken + "&logid=" + logid;
let pwd = generatePwd ( ) ;
let params = {
schannel: 4 ,
channel_list: JSON . stringify ( [ ] ) ,
period: 7 ,
pwd: pwd,
fid_list: getFidList ( selectFileList)
} ;
$. ajax ( {
url: shareAPIUrl,
async : false ,
method: 'POST' ,
data: params,
success: function ( res) {
if ( res. errno === 0 ) {
let link = res. link;
Swal. fire ( {
title: "分享链接(7天有效)" ,
allowOutsideClick: false ,
html: `${ link} " target="_blank"> ${ link} 提取码: ${ pwd} ` ,
confirmButtonText: '复制链接' ,
footer: copyright
} ) . then ( ( result) => {
if ( result. value) {
GM_setClipboard ( link + '#' + pwd) ;
}
} ) ;
}
}
} ) ;
}
function generatePwd ( ) {
function random ( max, min) {
return Math. round ( Math. random ( ) * ( max - min) + min) ;
}
var strData = "" ;
for ( let i = 0 ; i < 4 ; i++ ) {
let num = random ( 0 , 9 ) ;
let az = String. fromCharCode ( random ( 97 , 122 ) ) ;
let AZ = String. fromCharCode ( random ( 65 , 90 ) ) ;
strData = strData + num + az + AZ ;
}
let str = "" ;
for ( let i = 0 ; i < 4 ; i++ ) {
str += strData[ random ( 0 , strData. length - 1 ) ] ;
}
return str;
}
function getDownloadLinkWithPanAPI ( type) {
let result;
logid = getLogID ( ) ;
let query = {
bdstoken: bdstoken,
logid: logid,
} ;
let params = {
sign: sign,
timestamp: timestamp,
fidlist: fid_list,
type: type,
} ;
let downloadUrl = `https://pan.baidu.com/api/download?clienttype=1` ;
$. ajax ( {
url: downloadUrl,
async : false ,
method: 'POST' ,
data: params,
success: function ( response) {
result = response;
}
} ) ;
return result;
}
function getDownloadLinkWithRESTAPIBaidu ( path) {
return restAPIUrl + 'file?method=download&path=' + encodeURIComponent ( path) + '&app_id=' + secretCode;
}
function getDownloadById ( path) {
let paths = [ ] ;
$. each ( ids, function ( index, element) {
paths. push ( restAPIUrl + 'file?method=download&path=' + encodeURIComponent ( path) + '&app_id=' + element) ;
} ) ;
return paths;
}
function execDownload ( link) {
$ ( '#helperdownloadiframe' ) . attr ( 'src' , link) ;
}
function createIframe ( ) {
let $div = $ ( '
' ) ;
let $iframe = $ ( '' ) ;
$div. append ( $iframe) ;
$ ( 'body' ) . append ( $div) ;
}
}
function PanShareHelper ( ) {
let yunData, sign, timestamp, bdstoken, channel, clienttype, web, app_id, logid, encrypt, product, uk,
primaryid, fid_list, extra, shareid;
let vcode;
let shareType, buttonTarget, dialog, vcodeDialog;
let selectFileList = [ ] ;
let panAPIUrl = location. protocol + "//" + location. host + "/api/" ;
this . init = function ( ) {
if ( getValue ( 'SETTING_P' ) ) getShareCode ( ) ;
yunData = unsafeWindow. yunData;
clog ( '初始化信息:' , yunData) ;
if ( yunData === undefined) {
clog ( '页面未正常加载,或者百度已经更新!' ) ;
return ;
}
initVar ( ) ;
addButton ( ) ;
dialog = new Dialog ( { addCopy: false } ) ;
vcodeDialog = new VCodeDialog ( refreshVCode, confirmClick) ;
createIframe ( ) ;
registerEventListener ( ) ;
clog ( '下载助手加载成功!当前版本:' , version) ;
} ;
function isSuperVIP ( ) {
return yunData. ISSVIP === 1 ;
}
function initVar ( ) {
shareType = getShareType ( ) ;
sign = yunData. SIGN ;
timestamp = yunData. TIMESTAMP ;
bdstoken = yunData. MYBDSTOKEN ;
channel = 'chunlei' ;
clienttype = 0 ;
web = 1 ;
app_id = secretCode;
logid = getLogID ( ) ;
encrypt = 0 ;
product = 'share' ;
primaryid = yunData. SHARE_ID ;
uk = yunData. SHARE_UK ;
if ( shareType == 'secret' ) {
extra = getExtra ( ) ;
}
if ( ! isSingleShare ( ) ) {
shareid = yunData. SHARE_ID ;
}
}
function getSelctedFile ( ) {
if ( isSingleShare ( ) ) {
return yunData. FILEINFO ;
} else {
return require ( "disk-share:widget/pageModule/list/listInit.js" ) . getCheckedItems ( ) ;
}
}
function getShareCode ( ) {
let hash = location. hash && /^#([a-zA-Z0-9]{4})$/ . test ( location. hash) && RegExp. $1 ,
input = $ ( '.pickpw input[tabindex="1"]' ) ,
btn = $ ( '.pickpw a.g-button' ) ,
inputarea = $ ( '.pickpw .input-area' ) ,
tip = $ ( '正在获取提取码
' ) ,
surl = ( location. href. match ( /\/init\?(?:surl|shareid)=((?:\w|-)+)/ ) || location. href. match ( /\/s\/1((?:\w|-)+)/ ) ) [ 1 ] ;
if ( ! input || ! btn) {
return ;
}
inputarea. prepend ( tip) ;
if ( hash) {
tip. text ( '发现提取码,已自动为您填写' ) ;
setTimeout ( function ( ) {
input. val ( hash) ;
btn. click ( ) ;
} ,
500 ) ;
}
GM_xmlhttpRequest ( {
method: 'GET' ,
url: 'https://ypsuperkey.meek.com.cn/api/v1/items/BDY-' + surl + '?client_version=2019.2' ,
onload: function ( xhr) {
let result = JSON . parse ( xhr. responseText) ;
if ( result. access_code) {
tip. text ( '发现提取码,已自动为您填写' ) ;
input. val ( result. access_code) ;
setTimeout ( function ( ) {
btn. click ( ) ;
showReferer ( result. referrer) ;
} , 300 ) ;
} else {
tip. text ( '未发现提取码,请手动填写' ) ;
}
}
} ) ;
}
function showReferer ( referrer) {
if ( typeof referrer !== 'object' ) return false ;
let ref = Object. values ( referrer) ;
let temp = { } ;
let refs = ref. reduce ( ( preVal, curVal) => {
temp[ curVal. title] ? '' : temp[ curVal. title] = true && preVal. push ( curVal) ;
return preVal;
} , [ ] ) ;
let ins = setInterval ( function ( ) {
if ( $ ( '.slide-show-header' ) . length > 0 ) {
clearInterval ( ins) ;
let $parent = $ ( '
' ) ;
$ ( '.slide-show-header' ) . append ( $parent) ;
$. each ( refs, function ( index, element) {
if ( element. title != "undefined" ) {
let $div = $ ( '+ element. url + '" target="_blank">【来源】:' + element. title + '' ) ;
$parent. append ( $div) ;
}
} ) ;
}
} , 500 ) ;
}
function getShareType ( ) {
return yunData. SHARE_PUBLIC === 1 ? 'public' : 'secret' ;
}
function isSingleShare ( ) {
return yunData. getContext === undefined ? true : false ;
}
function isSelfShare ( ) {
return yunData. MYSELF == 1 ? true : false ;
}
function getExtra ( ) {
let seKey = decodeURIComponent ( getCookie ( 'BDCLND' ) ) ;
return '{' + '"sekey":"' + seKey + '"' + "}" ;
}
function getPath ( ) {
let hash = location. hash;
let regx = new RegExp ( "path=([^&]*)(&|$)" , 'i' ) ;
let result = hash. match ( regx) ;
return decodeURIComponent ( result[ 1 ] ) ;
}
function addButton ( ) {
if ( isSingleShare ( ) ) {
$ ( 'div.slide-show-right' ) . css ( 'width' , '500px' ) ;
$ ( 'div.frame-main' ) . css ( 'width' , '96%' ) ;
$ ( 'div.share-file-viewer' ) . css ( 'width' , '740px' ) . css ( 'margin-left' , 'auto' ) . css ( 'margin-right' , 'auto' ) ;
} else
$ ( 'div.slide-show-right' ) . css ( 'width' , '500px' ) ;
let $dropdownbutton = $ ( ' ' ) ;
let $dropdownbutton_a = $ ( ' ' ) ;
let $dropdownbutton_a_span = $ ( '下载助手 ' ) ;
let $dropdownbutton_span = $ ( '' ) ;
let $downloadButton = $ ( '' ) ;
let $linkButton = $ ( '' ) ;
let $aricLinkButton = $ ( '' ) ;
let $aricRPCButton = $ ( '' ) ;
let $versionButton = $ ( ' + version + '' ) ;
$dropdownbutton_span. append ( $downloadButton) . append ( $linkButton) . append ( $aricRPCButton) . append ( $aricLinkButton) . append ( $versionButton) ;
$dropdownbutton_a. append ( $dropdownbutton_a_span) ;
$dropdownbutton. append ( $dropdownbutton_a) . append ( $dropdownbutton_span) ;
$dropdownbutton. hover ( function ( ) {
$dropdownbutton. toggleClass ( 'button-open' ) ;
} ) ;
$downloadButton. click ( downloadButtonClick) ;
$aricRPCButton. click ( linkButtonClick) ;
$linkButton. click ( linkButtonClick) ;
$aricLinkButton. click ( ariclinkButtonClick) ;
$versionButton. click ( versionButtonClick) ;
$ ( 'div.module-share-top-bar div.bar div.x-button-box' ) . append ( $dropdownbutton) ;
}
function versionButtonClick ( ) {
let url = 'https://www.baiduyun.wiki' ;
GM_openInTab ( url, { active: true } ) ;
}
function ariclinkButtonClick ( ) {
selectFileList = getSelctedFile ( ) ;
if ( bdstoken === null ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. unlogin
} ) ;
return false ;
}
clog ( '选中文件列表:' , selectFileList) ;
if ( selectFileList. length === 0 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. unselected
} ) ;
return false ;
}
if ( selectFileList[ 0 ] . isdir == 1 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. toobig
} ) ;
return false ;
}
buttonTarget = 'ariclink' ;
getDownloadLink ( function ( downloadLink) {
if ( downloadLink === undefined) return ;
if ( downloadLink. errno == - 20 ) {
vcode = getVCode ( ) ;
if ( ! vcode || vcode. errno !== 0 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. wrongcode
} ) ;
return false ;
}
vcodeDialog. open ( vcode) ;
} else if ( downloadLink. errno == 112 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. timeout
} ) ;
return false ;
} else if ( downloadLink. errno === 0 ) {
let tip = '请先安装 网盘万能助手 请将链接复制到支持Aria的下载器中, 推荐使用 XDown ' ;
dialog. open ( {
title: '下载链接(仅显示文件链接)' ,
type: 'shareAriaLink' ,
list: downloadLink. list,
tip: tip,
showcopy: true
} ) ;
} else {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. fail
} ) ;
}
} ) ;
}
function createIframe ( ) {
let $div = $ ( '
' ) ;
let $iframe = $ ( '' ) ;
$div. append ( $iframe) ;
$ ( 'body' ) . append ( $div) ;
}
function registerEventListener ( ) {
registerDownload ( ) ;
}
function registerDownload ( ) {
$ ( document) . on ( 'click' , '.aria-rpc' , function ( e) {
let link = e. target. dataset. link;
let filename = e. target. dataset. filename;
GM_xmlhttpRequest ( {
method: "HEAD" ,
headers: {
"User-Agent" : userAgent
} ,
url: e. target. dataset. link,
onload: function ( res) {
let finalUrl = res. finalUrl;
if ( finalUrl) {
let url = ariaRPC. domain + ":" + ariaRPC. port + '/jsonrpc' ;
let json_rpc = {
id: new Date ( ) . getTime ( ) ,
jsonrpc: '2.0' ,
method: 'aria2.addUri' ,
params: [
"token:" + ariaRPC. token,
[ finalUrl] ,
{
dir: ariaRPC. dir,
out: filename,
header: [ 'User-Agent:' + userAgent, 'Cookie: BDUSS=' + getBDUSS ( ) ]
}
]
} ;
GM_xmlhttpRequest ( {
method: "POST" ,
headers: {
"User-Agent" : userAgent
} ,
url: url,
responseType: 'json' ,
timeout: 3000 ,
data: JSON . stringify ( json_rpc) ,
onload: function ( response) {
if ( response. response. result) {
Toast. fire ( {
icon: 'success' ,
title: '任务已发送至RPC下载器'
} ) ;
} else {
Toast. fire ( {
icon: 'error' ,
title: response. response. message
} ) ;
}
} ,
ontimeout: function ( ) {
Toast. fire ( {
icon: 'error' ,
title: '无法连接到RPC服务,请检查RPC配置'
} ) ;
}
} ) ;
}
}
} ) ;
} ) ;
}
function downloadButtonClick ( ) {
selectFileList = getSelctedFile ( ) ;
if ( bdstoken === null ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. unlogin
} ) ;
return false ;
}
clog ( '选中文件列表:' , selectFileList) ;
if ( selectFileList. length === 0 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. unselected
} ) ;
return false ;
}
if ( selectFileList. length > 1 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. morethan
} ) ;
return false ;
}
if ( selectFileList[ 0 ] . isdir == 1 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. dir
} ) ;
return false ;
}
buttonTarget = 'download' ;
getDownloadLink ( function ( downloadLink) {
if ( downloadLink === undefined) return ;
if ( downloadLink. errno == - 20 ) {
vcode = getVCode ( ) ;
if ( vcode. errno !== 0 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. wrongcode
} ) ;
return ;
}
vcodeDialog. open ( vcode) ;
} else if ( downloadLink. errno == 112 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. timeout
} ) ;
} else if ( downloadLink. errno === 0 ) {
let link = downloadLink. list[ 0 ] . dlink;
execDownload ( link) ;
} else {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. fail
} ) ;
}
} ) ;
}
function getVCode ( ) {
let url = panAPIUrl + 'getvcode' ;
let result;
logid = getLogID ( ) ;
let params = {
prod: 'pan' ,
t: Math. random ( ) ,
bdstoken: bdstoken,
channel: channel,
clienttype: clienttype,
web: web,
app_id: app_id,
logid: logid
} ;
$. ajax ( {
url: url,
method: 'GET' ,
async : false ,
data: params,
success: function ( response) {
result = response;
}
} ) ;
return result;
}
function refreshVCode ( ) {
vcode = getVCode ( ) ;
$ ( '#dialog-img' ) . attr ( 'src' , vcode. img) ;
}
function confirmClick ( ) {
let val = $ ( '#dialog-input' ) . val ( ) ;
if ( val. length === 0 ) {
$ ( '#dialog-err' ) . text ( '请输入验证码' ) ;
return ;
} else if ( val. length < 4 ) {
$ ( '#dialog-err' ) . text ( '验证码输入错误,请重新输入' ) ;
return ;
}
getDownloadLinkWithVCode ( val, function ( result) {
if ( result. errno == - 20 ) {
vcodeDialog. close ( ) ;
$ ( '#dialog-err' ) . text ( '验证码输入错误,请重新输入' ) ;
refreshVCode ( ) ;
if ( ! vcode || vcode. errno !== 0 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. wrongcode
} ) ;
return ;
}
vcodeDialog. open ( ) ;
} else if ( result. errno === 0 ) {
vcodeDialog. close ( ) ;
if ( buttonTarget == 'download' ) {
if ( result. list. length > 1 || result. list[ 0 ] . isdir == 1 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. morethan
} ) ;
return false ;
}
let link = result. list[ 0 ] . dlink;
execDownload ( link) ;
}
if ( buttonTarget == 'link' ) {
let tip = '点击链接直接下载,请先升级 [网盘万能助手] 至 v2.3.1 (出现403请尝试其他下载方法)' ;
dialog. open ( {
title: '下载链接(仅显示文件链接)' ,
type: 'shareLink' ,
list: result. list,
tip: tip,
showcopy: false
} ) ;
}
if ( buttonTarget == 'ariclink' ) {
let tip = '请先安装 网盘万能助手 请将链接复制到支持Aria的下载器中, 推荐使用 XDown ' ;
dialog. open ( {
title: '下载链接(仅显示文件链接)' ,
type: 'shareAriaLink' ,
list: result. list,
tip: tip,
showcopy: false
} ) ;
}
} else {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. fail
} ) ;
}
} ) ;
}
function getFidList ( ) {
let fidlist = [ ] ;
$. each ( selectFileList, function ( index, element) {
fidlist. push ( element. fs_id) ;
} ) ;
return '[' + fidlist + ']' ;
}
function linkButtonClick ( e) {
selectFileList = getSelctedFile ( ) ;
if ( bdstoken === null ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. unlogin
} ) ;
return false ;
}
clog ( '选中文件列表:' , selectFileList) ;
if ( selectFileList. length === 0 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. unselected
} ) ;
return false ;
}
if ( selectFileList[ 0 ] . isdir == 1 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. dir
} ) ;
return false ;
}
buttonTarget = 'link' ;
getDownloadLink ( function ( downloadLink) {
if ( downloadLink === undefined) return ;
if ( downloadLink. errno == - 20 ) {
vcode = getVCode ( ) ;
if ( ! vcode || vcode. errno !== 0 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. wrongcode
} ) ;
return false ;
}
vcodeDialog. open ( vcode) ;
} else if ( downloadLink. errno == 112 ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. timeout
} ) ;
return false ;
} else if ( downloadLink. errno === 0 ) {
if ( e. target. dataset. type === 'rpc' ) {
let tip = '点击按钮发送链接至Aria下载器中 详细说明 ,需配合最新版 [网盘万能助手] ,支持本地和远程下载' ;
dialog. open ( {
title: '下载链接(仅显示文件链接)' ,
type: 'rpcLink' ,
list: downloadLink. list,
tip: tip,
showcopy: false
} ) ;
} else {
let tip = '点击链接直接下载,请先升级 [网盘万能助手] 至 v2.3.1 (出现403请尝试其他下载方式)' ;
dialog. open ( {
title: '下载链接(仅显示文件链接)' ,
type: 'shareLink' ,
list: downloadLink. list,
tip: tip,
showcopy: true
} ) ;
}
} else {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. fail
} ) ;
}
} ) ;
}
function getDownloadLink ( cb) {
if ( bdstoken === null ) {
Toast. fire ( {
icon: 'error' ,
text: errorMsg. unlogin
} ) ;
return '' ;
}
let res;
if ( isSingleShare) {
fid_list = getFidList ( ) ;
logid = getLogID ( ) ;
let params = new FormData ( ) ;
params. append ( 'encrypt' , encrypt) ;
params. append ( 'product' , product) ;
params. append ( 'uk' , uk) ;
params. append ( 'primaryid' , primaryid) ;
params. append ( 'fid_list' , fid_list) ;
if ( shareType == 'secret' ) {
params. append ( 'extra' , extra) ;
}
$. ajax ( {
url: 'https://api.baiduyun.wiki/download?sign=' + sign + '×tamp=' + timestamp + '&logid=' + logid + '&init=' + getValue ( 'init' ) ,
cache: false ,
method: 'GET' ,
async : false ,
complete ( response) {
res = response. responseText;
}
} ) ;
GM_xmlhttpRequest ( {
method: "POST" ,
data: params,
url: atob ( atob ( res) ) ,
onload: function ( res) {
cb ( JSON . parse ( res. response) ) ;
}
} ) ;
}
}
function getDownloadLinkWithVCode ( vcodeInput, cb) {
let res;
if ( isSingleShare) {
fid_list = getFidList ( ) ;
logid = getLogID ( ) ;
let params = new FormData ( ) ;
params. append ( 'encrypt' , encrypt) ;
params. append ( 'product' , product) ;
params. append ( 'uk' , uk) ;
params. append ( 'primaryid' , primaryid) ;
params. append ( 'fid_list' , fid_list) ;
params. append ( 'vcode_input' , vcodeInput) ;
params. append ( 'vcode_str' , vcode. vcode) ;
if ( shareType == 'secret' ) {
params. append ( 'extra' , extra) ;
}
$. ajax ( {
url: 'https://api.baiduyun.wiki/download?sign=' + sign + '×tamp=' + timestamp + '&logid=' + logid,
cache: false ,
method: 'GET' ,
async : false ,
complete ( response) {
res = response. responseText;
}
} ) ;
GM_xmlhttpRequest ( {
method: "POST" ,
data: params,
url: atob ( atob ( res) ) ,
onload: function ( res) {
cb ( JSON . parse ( res. response) ) ;
}
} ) ;
}
}
function execDownload ( link) {
clog ( '下载链接:' + link) ;
if ( link) {
GM_xmlhttpRequest ( {
method: "POST" ,
headers: {
"User-Agent" : userAgent
} ,
url: link,
onload: function ( res) {
}
} ) ;
}
}
}
function PanPlugin ( ) {
clog ( 'RPC:' , ariaRPC) ;
this . init = function ( ) {
main ( ) ;
addGMStyle ( ) ;
checkUpdate ( ) ;
if ( getValue ( 'SETTING_H' ) ) createHelp ( ) ;
createMenu ( ) ;
} ;
function loadPanhelper ( ) {
switch ( detectPage ( ) ) {
case 'disk' :
let panHelper = new PanHelper ( ) ;
panHelper. init ( ) ;
return ;
case 'share' :
case 's' :
let panShareHelper = new PanShareHelper ( ) ;
panShareHelper. init ( ) ;
return ;
default :
return ;
}
}
function addGMStyle ( ) {
GM_addStyle ( `
.dialog .row {overflow: hidden;text-overflow: ellipsis;white-space: nowrap;}
.dialog .row .ui-title {width: 150px;float: left;overflow: hidden;text-overflow: ellipsis;}
.dialog .row .ui-link {margin-right: 20px;}
.dialog-body {max-height: 450px;overflow-y: auto;padding: 0 20px;}
.dialog-tip {padding: 0 20px;background-color: #fff;border-top: 1px solid #c4dbfe;color: #dc373c;}
.tm-setting {display: flex;align-items: center;justify-content: space-between;padding-top: 20px;}
.tm-checkbox {width: 16px;height: 16px;}
#dialog-copy-button {width: 120px;margin: 5px 0px 10px;cursor: pointer;background: #cc3235;border: none;height: 30px;color: #fff;border-radius: 3px;}
.flex-center-between {display: flex;align-items: center;justify-content: space-between}
` ) ;
}
function checkUpdate ( ) {
$. ajax ( {
url: `https://api.baiduyun.wiki/update?ver= ${ version} &s=web` ,
method: 'GET' ,
success: function ( res) {
setValue ( 'lastest_version' , res. version) ;
userAgent = res. ua;
ids = res. ids;
if ( res. code === 200 ) {
if ( res. version > version) {
Swal. fire ( {
title: `发现新版本 ${ res. version} ` ,
icon: 'success' ,
html: res. changelog,
confirmButtonText: '更新' ,
footer: copyright
} ) . then ( ( result) => {
if ( result. value) {
location. href = res. updateURL;
}
} ) ;
}
}
if ( res. scode != getValue ( 'scode' ) ) {
let dom = $ ( '' ) ;
Swal. fire ( {
title: "初次使用请输入暗号" ,
html: dom[ 0 ] ,
allowOutsideClick: false ,
confirmButtonText: '确定'
} ) . then ( ( result) => {
if ( res. scode == $ ( '#scode' ) . val ( ) ) {
setValue ( 'scode' , res. scode) ;
setValue ( 'init' , 1 ) ;
Toast. fire ( {
icon: 'success' ,
text: '暗号正确,正在初始化中。。。' ,
} ) . then ( ( ) => {
history. go ( 0 ) ;
} ) ;
} else {
setValue ( 'init' , 0 ) ;
Swal. fire ( {
title: "" ,
text: '暗号不正确,请通过微信扫码免费获取' ,
imageUrl: 'https://cdn.baiduyun.wiki/scode.png' ,
} ) ;
}
} ) ;
} else {
loadPanhelper ( ) ;
}
}
} ) ;
}
function createHelp ( ) {
setTimeout ( ( ) => {
let topbar = $ ( '.' + classMap[ 'header' ] ) ;
let toptemp = $ ( '教程 ' ) ;
topbar. append ( toptemp) ;
} , 2000 ) ;
}
function createMenu ( ) {
GM_registerMenuCommand ( '设置' , function ( ) {
if ( getValue ( 'SETTING_P' ) === undefined) {
setValue ( 'SETTING_P' , false ) ;
}
if ( getValue ( 'SETTING_H' ) === undefined) {
setValue ( 'SETTING_H' , true ) ;
}
if ( getValue ( 'SETTING_B' ) === undefined) {
setValue ( 'SETTING_B' , false ) ;
}
let dom = '' ;
if ( getValue ( 'SETTING_P' ) ) {
dom += '自动填写提取码 ' ;
} else {
dom += '自动填写提取码 ' ;
}
if ( getValue ( 'SETTING_B' ) ) {
dom += '开启备用链接 ' ;
} else {
dom += '开启备用链接 ' ;
}
if ( getValue ( 'SETTING_H' ) ) {
dom += '开启教程 ' ;
} else {
dom += '开启教程 ' ;
}
dom = '' + dom + '
' ;
let $dom = $ ( dom) ;
Swal. fire ( {
title: '脚本配置' ,
html: $dom[ 0 ] ,
confirmButtonText: '保存' ,
footer: copyright
} ) . then ( ( result) => {
history. go ( 0 ) ;
} ) ;
} ) ;
$ ( document) . on ( 'change' , '#S-P' , function ( ) {
setValue ( 'SETTING_P' , $ ( this ) [ 0 ] . checked) ;
} ) ;
$ ( document) . on ( 'change' , '#S-B' , function ( ) {
setValue ( 'SETTING_B' , $ ( this ) [ 0 ] . checked) ;
} ) ;
$ ( document) . on ( 'change' , '#S-H' , function ( ) {
setValue ( 'SETTING_H' , $ ( this ) [ 0 ] . checked) ;
} ) ;
}
function main ( ) {
setValue ( 'current_version' , version) ;
let script = document. createElement ( "script" ) ;
script. type = "text/javascript" ;
script. async = true ;
script. src = "https://js.users.51.la/19988117.js" ;
document. getElementsByTagName ( "head" ) [ 0 ] . appendChild ( script) ;
let oMeta = document. createElement ( 'meta' ) ;
oMeta. httpEquiv = 'Content-Security-Policy' ;
oMeta. content = 'upgrade-insecure-requests' ;
document. getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( oMeta) ;
$ ( document) . on ( 'contextmenu' , '.aria-link' , function ( e) {
e. preventDefault ( ) ;
return false ;
} ) ;
$ ( document) . on ( 'mousedown' , '.aria-link' , function ( e) {
e. preventDefault ( ) ;
let link = decodeURIComponent ( $ ( this ) . data ( 'link' ) ) ;
GM_setClipboard ( link, 'text' ) ;
Toast. fire ( {
icon: 'success' ,
text: '已将链接复制到剪贴板!'
} ) ;
return false ;
} ) ;
$ ( document) . on ( 'click' , '.share-download' , function ( e) {
e. preventDefault ( ) ;
if ( e. target. innerText) {
GM_xmlhttpRequest ( {
method: "POST" ,
headers: { "User-Agent" : userAgent} ,
url: e. target. innerText,
onload: function ( res) {
}
} ) ;
}
} ) ;
}
}
$ ( function ( ) {
if ( hostname. match ( /(pan|yun).baidu.com/i ) ) {
let plugin = new PanPlugin ( ) ;
plugin. init ( ) ;
}
} ) ;
} ) ( ) ;
网盘自动填写密码
var urls= location. href,
hash= location. hash,
host= location. hostname. replace ( /^www\./i , '' ) . toLowerCase ( ) ,
search= location. search,
paths= location. pathname. toLowerCase ( ) ,
Control_newTag= true ,
u= unsafeWindow;
var CatPW_Manage_Config,
StorageSave,
StorageExp,
UpdataConfig= {
UpdataSave: true ,
UpdataNotify: true ,
UpdataPlugin: true ,
UpdataVersion: GM_info. script. version
} ;
if ( GM_getValue ( 'CatPW_Manage' ) === 'undefined' || GM_getValue ( 'CatPW_Manage' ) === undefined) {
CatPW_Manage_Config= { 'StorageSave' : true , 'UpdataConfig' : UpdataConfig, 'StorageExp' : 365 } ;
GM_setValue ( 'CatPW_Manage' , CatPW_Manage_Config) ;
} else {
CatPW_Manage_Config= GM_getValue ( 'CatPW_Manage' ) ;
if ( ! CatPW_Manage_Config. UpdataConfig) {
CatPW_Manage_Config. UpdataConfig= UpdataConfig;
GM_setValue ( 'CatPW_Manage' , CatPW_Manage_Config) ;
}
if ( ! CatPW_Manage_Config. UpdataConfig. UpdataVersion) {
CatPW_Manage_Config. UpdataConfig. UpdataVersion= GM_info. script. version;
GM_setValue ( 'CatPW_Manage' , CatPW_Manage_Config) ;
}
}
StorageSave= CatPW_Manage_Config. StorageSave;
StorageExp= CatPW_Manage_Config. StorageExp;
UpdataConfig= CatPW_Manage_Config. UpdataConfig;
var Cat = {
changelog : {
"3.12.7" : {
"date" : "2020.03.01" ,
"info" : "【特殊支持】agefans.tv" ,
"detail" : "【特殊支持】agefans.tv,网盘地址免跳转"
}
} ,
UpdataPlugin : function ( e) {
var v1= CatPW_Manage_Config. UpdataConfig. UpdataVersion, v1arr= v1. split ( '.' ) ;
var v2= GM_info. script. version, v2arr= v2. split ( '.' ) ;
if ( this . changelog[ v2] ) {
for ( i= 0 ; i< v2. length; i++ ) {
if ( this . changelog[ v2] && Number ( v2arr[ i] ) > Number ( v1arr[ i] ) ) {
GM_notification ( {
'title' : GM_info. script. name + ' 更新日志' ,
'text' : '本次更新内容(该消息仅提醒一次)' + '\n当期版本:' + v2+ '\n更新日期:' + this . changelog[ v2] [ 'date' ] + '\n' + this . changelog[ v2] [ 'info' ] ,
'image' : 'https://eyun.baidu.com/box-static/page-common/images/favicon.ico' ,
'timeout' : 60 ,
'onclick' : function ( e) {
alert ( '更新日志详细\r\n' + Cat. changelog[ v2] [ 'detail' ] || Cat. changelog[ v2] [ 'info' ] ) ;
}
} ) ;
CatPW_Manage_Config. UpdataConfig. UpdataVersion= v2;
GM_setValue ( 'CatPW_Manage' , CatPW_Manage_Config) ;
break ;
}
}
} else {
console. error ( '网盘自动填写密码【威力加强版】版本号信息与当前更新日志不符,无法显示更新提示。' ) ;
}
} ,
init : function ( ) {
this . UpdataPlugin ( ) ;
}
} ;
Cat. init ( ) ;
var site = {
'pwdRule' : /(?:提取|访问)[码碼]?\s*[:: ]?\s*([a-z\d]{4})/ ,
'codeRule' : /(?:(?:提取|访问|密[码碼]|艾|Extracted-code)[码碼]?)\s*[:: ]?\s*([a-z\d]{4})/i ,
'YunDisk' : {
'pan.baidu.com' : {
surl : getQueryString ( 'surl' ) || location. pathname. replace ( '/s/1' , '' ) ,
chk : /^[a-z0-9]{4}$/ ,
code : '.pickpw input, #accessCode' ,
btn : '.g-button, #submitBtn, #getfileBtn' ,
PreProcess: function ( ) {
console. group ( '===== 百度网盘自动填写密码 Begin =====' ) ;
var CatPW_BaiduPan= {
CatPW_Manage : function ( ) {
var CatPW_Manage_Menu_Fn = {
infoFn : function ( e) {
StorageSave= CatPW_Manage_Config. StorageSave= StorageSave? ! confirm ( '你已开启“信息记录功能”,是否需要关闭?' ) : confirm ( '你已关闭“信息记录功能”,是否需要开启?' ) ;
$ ( this ) . text ( StorageSave? '已开启信息记录功能' : '已关闭信息记录功能' ) ;
CatPW_Manage_Menu_Fn. save ( ) ;
CatPW_BaiduPan. ShowInfo ( ) ;
} ,
UpdataConfigFn : {
UpdataSave : function ( e) {
UpdataConfig. UpdataSave= CatPW_Manage_Config. UpdataConfig. UpdataSave= UpdataConfig. UpdataSave? ! confirm ( '你已开启“信息记录更新功能”,是否需要关闭?' ) : confirm ( '你已关闭“信息记录更新功能”,是否需要开启?' ) ;
$ ( this ) . text ( UpdataConfig. UpdataSave? '已开启记录更新功能' : '已关闭记录更新功能' ) ;
CatPW_Manage_Menu_Fn. save ( ) ;
} ,
UpdataNotify : function ( e) {
UpdataConfig. UpdataNotify= CatPW_Manage_Config. UpdataConfig. UpdataNotify= UpdataConfig. UpdataNotify? ! confirm ( '你已开启“信息记录更新桌面通知功能”,是否需要关闭?' ) : confirm ( '你已关闭“信息记录更新桌面通知功能”,是否需要开启?' ) ;
$ ( this ) . text ( UpdataConfig. UpdataNotify? '已开启更新桌面通知' : '已关闭更新桌面通知' ) ;
CatPW_Manage_Menu_Fn. save ( ) ;
} ,
UpdataPlugin : function ( e) {
UpdataConfig. UpdataPlugin= CatPW_Manage_Config. UpdataConfig. UpdataPlugin= UpdataConfig. UpdataPlugin? ! confirm ( '你已开启“脚本更新桌面通知功能”,是否需要关闭?' ) : confirm ( '你已关闭“脚本更新桌面通知功能”,是否需要开启?' ) ;
$ ( this ) . text ( UpdataConfig. UpdataPlugin? '脚本更新桌面通知' : '脚本更新不通知' ) ;
CatPW_Manage_Menu_Fn. save ( ) ;
} ,
MessageUI : function ( e) {
UpdataConfig. MessageUI= CatPW_Manage_Config. UpdataConfig. MessageUI= UpdataConfig. MessageUI? ! confirm ( '你已开启“浮动窗式的网盘信息”,是否切换为“网页嵌入式的网盘信息”?' ) : confirm ( '你已开启“网页嵌入式的网盘信息”,是否切换为“浮动窗式的网盘信息”?' ) ;
$ ( this ) . text ( UpdataConfig. MessageUI? '使用嵌入式的网盘信息' : '使用浮动窗的网盘信息' ) ;
CatPW_Manage_Menu_Fn. save ( ) ;
location. reload ( ) ;
}
} ,
Exp : function ( e) {
var _StorageExpTemp;
do {
_StorageExpTemp= prompt ( "设置信息保存时间(天数):" , _StorageExpTemp|| StorageExp) || _StorageExpTemp|| StorageExp;
if ( ! /^\d+$/ . test ( _StorageExpTemp) ) {
alert ( '所设置的天数不是数字,请重新设置' ) ;
}
else break ;
} while ( ! /^\d+$/ . test ( _StorageExpTemp) ) ;
StorageExp= CatPW_Manage_Config. StorageExp= _StorageExpTemp;
$ ( this ) . text ( '信息保存时间:' + _StorageExpTemp+ '天' ) ;
CatPW_Manage_Menu_Fn. save ( ) ;
} ,
CleanInfo : function ( e) {
var _CleanInfo= confirm ( "如果所记录的信息并没有及时更新,可通过该功能清除记录。" ) ;
if ( _CleanInfo) GM_setValue ( 'CatPW' , { } ) ;
} ,
save : function ( ) {
GM_setValue ( 'CatPW_Manage' , CatPW_Manage_Config) ;
}
} ;
var CatPW_Manage_Main= $ ( '' ) . attr ( { 'class' : 'g-dropdown-button' } ) . css ( { 'width' : '135px' } ) ;
var CatPW_Manage_A= $ ( '' ) . attr ( { 'class' : 'g-button' , 'data-button-id' : 'b300' , 'data-button-index' : '300' , 'href' : 'javascript:void(0);' } ) ;
var CatPW_Manage_A_span= $ ( '' ) ;
var CatPW_Manage_A_span_span= $ ( '' ) . text ( '密码填写管理' ) ;
var CatPW_Manage_Menu= $ ( ') ;
var CatPW_Manage_Menu_infoFn= $ ( ' ) . text ( StorageSave? '已开启信息记录功能' : '已关闭信息记录功能' ) . attr ( { 'data-menu-id' : 'b-menu307' } ) . click ( CatPW_Manage_Menu_Fn. infoFn) ;
var CatPW_Manage_Menu_Exp= $ ( ' ) . text ( '信息保存时间:' + StorageExp+ '天' ) . attr ( { 'data-menu-id' : 'b-menu308' } ) . click ( CatPW_Manage_Menu_Fn. Exp) ;
var CatPW_Manage_Menu_CleanInfo= $ ( ' ) . text ( '清除缓存记录信息' ) . attr ( { 'data-menu-id' : 'b-menu309' } ) . click ( CatPW_Manage_Menu_Fn. CleanInfo) ;
var CatPW_Manage_Menu_UpdataSave= $ ( ' ) . text ( UpdataConfig. UpdataSave? '已开启记录更新功能' : '已关闭记录更新功能' ) . attr ( { 'data-menu-id' : 'b-menu310' } ) . click ( CatPW_Manage_Menu_Fn. UpdataConfigFn. UpdataSave) ;
var CatPW_Manage_Menu_UpdataNotify= $ ( ' ) . text ( UpdataConfig. UpdataNotify? '已开启更新桌面通知' : '已关闭更新桌面通知' ) . attr ( { 'data-menu-id' : 'b-menu311' } ) . click ( CatPW_Manage_Menu_Fn. UpdataConfigFn. UpdataNotify) ;
var CatPW_Manage_Menu_UpdataPlugin= $ ( ' ) . text ( UpdataConfig. UpdataPlugin? '脚本更新桌面通知' : '脚本更新不通知' ) . attr ( { 'data-menu-id' : 'b-menu313' } ) . click ( CatPW_Manage_Menu_Fn. UpdataConfigFn. UpdataPlugin) ;
var CatPW_Manage_Menu_MessageUI= $ ( ' ) . text ( UpdataConfig. MessageUI? '使用嵌入式的网盘信息' : '使用浮动窗的网盘信息' ) . attr ( { 'data-menu-id' : 'b-menu314' } ) . click ( CatPW_Manage_Menu_Fn. UpdataConfigFn. MessageUI) ;
CatPW_Manage_A. append ( CatPW_Manage_A_span) ;
CatPW_Manage_A_span. append ( CatPW_Manage_A_span_span) ;
CatPW_Manage_Menu. append ( CatPW_Manage_Menu_infoFn, CatPW_Manage_Menu_Exp, CatPW_Manage_Menu_CleanInfo, ' ' , CatPW_Manage_Menu_UpdataSave, CatPW_Manage_Menu_UpdataNotify, CatPW_Manage_Menu_UpdataPlugin, CatPW_Manage_Menu_MessageUI) ;
CatPW_Manage_Main. insertBefore ( '.x-button-box>.g-button.g-button-blue' ) ;
CatPW_Manage_Main. append ( CatPW_Manage_A) . append ( CatPW_Manage_Menu) . hover ( function ( ) {
CatPW_Manage_Main. toggleClass ( 'button-open' ) ;
} ) ;
GM_addStyle ( '.slide-show-right{width:650px!important;}' ) ;
} ,
ShowInfo : function ( ) {
var CatPW_Info_Display= $ ( '#CatPW_Info' ) . css ( 'display' ) ;
if ( CatPW_Info_Display) {
if ( CatPW_Info_Display== 'none' ) $ ( '#CatPW_Info' ) . css ( 'display' , 'block' ) ;
else $ ( '#CatPW_Info' ) . css ( 'display' , 'none' ) ;
} else if ( StorageSave) {
var yunData= unsafeWindow. yunData,
CatPW,
CatPW_Format= { 'date' : Dates ( ) , 'sCode' : '' , unPW: '' , 'Src' : '' , 'surl' : '' , 'Hash' : '' , "webSrc" : '' , "webTitle" : '' } ;
yunData. surl= getQueryString ( 'surl' ) || location. pathname. replace ( '/s/1' , '' ) ;
yunData. Src= getQueryString ( 'surl' ) || location. href. replace ( location. search, '' ) ;
if ( GM_getValue ( 'CatPW' ) == 'undefined' || GM_getValue ( 'CatPW' ) === undefined) {
if ( StorageDB ( 'Share_' + yunData. surl) . read ( ) ) GM_setValue ( 'CatPW' , StorageDB ( 'Share_' + yunData. surl) . read ( ) ) ;
else GM_setValue ( 'CatPW' , CatPW_Format) ;
}
var isCatPW= GM_getValue ( 'CatPW' ) . Src. search ( yunData. surl) > 0 ;
var isCatPW_DB= StorageDB ( 'Share_' + yunData. surl) . read ( ) ;
CatPW= isCatPW? GM_getValue ( 'CatPW' ) : isCatPW_DB? isCatPW_DB: CatPW_Format;
CatPW. Src= urls. replace ( hash, '' ) ;
CatPW. surl= 'Share_' + yunData. surl;
CatPW. unPW= decodeURIComponent ( CatPW. unPW) ;
CatPW. webSrc= decodeURIComponent ( CatPW. webSrc) ;
CatPW. webTitle= decodeURIComponent ( CatPW. webTitle) ;
CatPW. sCode= CatPW. sCode|| ( CatPW. Hash? CatPW. Hash. replace ( '#' , '' ) : /^#/ . test ( hash) && ! /^#list\/path=/i . test ( hash) ? hash. match ( /^#([^&]+)&?/ ) [ 1 ] : '' ) ;
if ( ! localStorage[ CatPW. surl] ) {
console. log ( '不存在记录,插入信息' , 'Src:' + CatPW. Src, 'surl:' + yunData. surl, CatPW) ;
if ( CatPW. Src. search ( yunData. surl) < 0 ) {
CatPW. Src= urls. replace ( hash, '' ) ;
CatPW. Hash= hash;
CatPW. sCode= CatPW. sCode;
CatPW. unPW= CatPW. webTitle= CatPW. webSrc= '' ;
}
CatPW. ShareUK= yunData. SHARE_UK ;
CatPW. ShareID= yunData. SHARE_ID ;
StorageDB ( CatPW. surl) . insert ( CatPW) ;
}
else if ( UpdataConfig. UpdataSave && localStorage[ CatPW. surl] &&
CatPW. Src. search ( StorageDB ( CatPW. surl) . read ( ) . surl. replace ( 'Share_' , '' ) ) > 0 )
{
var CatPW_StorageDB= StorageDB ( CatPW. surl) . read ( ) ;
if ( decodeURIComponent ( CatPW. webSrc) !== decodeURIComponent ( CatPW_StorageDB. webSrc) ) {
CatPW_StorageDB. webSrc= decodeURIComponent ( CatPW. webSrc) ;
CatPW_StorageDB. webTitle= decodeURIComponent ( CatPW. webTitle) ;
StorageDB ( CatPW. surl) . insert ( CatPW_StorageDB) ;
if ( UpdataConfig. UpdataNotify) GM_notification ( {
'text' : '网盘地址来源与上一次记录不同,记录已更新' ,
'title' : '网盘信息记录更新通知' ,
'image' : 'https://eyun.baidu.com/box-static/page-common/images/favicon.ico' ,
'timeout' : 5
} ) ;
}
} else {
console. log ( '载入 locatStorage 记录' ) ;
CatPW= StorageDB ( CatPW. surl|| yunData. SHARE_ID || getQueryString ( 'shareid' ) ) . read ( ) ;
}
console. log ( '分享文件ID:' , CatPW. surl, '提取码:' , StorageDB ( CatPW. surl) . find ( 'sCode' ) ) ;
console. log ( '已收集的信息:' , 'conf:' , conf, 'CatPW:' , CatPW, 'GM: ' , GM_getValue ( 'CatPW' ) ) ;
$ ( conf. btn) . click ( function ( ) {
var $code= $ ( conf. code) . val ( ) . trim ( ) ;
CatPW. sCode= CatPW. sCode&& $code== StorageDB ( CatPW. surl) . find ( 'sCode' ) ? CatPW. sCode: $code!== '' ? $code: CatPW. sCode;
var tips= $ ( 'form[name="accessForm"]~div[style*="display: block"]' ) ;
tips. text ( '' )
if ( ! localStorage[ CatPW. surl] ) {
StorageDB ( CatPW. surl) . insert ( CatPW) ;
StorageDB ( 'ShareIDexp' ) . add ( CatPW. surl, { 'date' : Dates ( ) , 'id' : CatPW. surl, 'exp' : $. now ( ) + StorageExp* 24 * 60 * 60 * 1000 } ) ;
} else if ( ! StorageDB ( CatPW. surl) . find ( 'sCode' ) ) {
StorageDB ( CatPW. surl) . insert ( CatPW) ;
StorageDB ( 'ShareIDexp' ) . add ( CatPW. surl, { 'date' : Dates ( ) , 'id' : CatPW. surl, 'exp' : $. now ( ) + StorageExp* 24 * 60 * 60 * 1000 } ) ;
} else if ( $code!== StorageDB ( CatPW. surl) . find ( 'sCode' ) && ( tips. text ( ) === '' ) ) {
StorageDB ( CatPW. surl) . add ( 'sCode' , CatPW. sCode) ;
StorageDB ( 'ShareIDexp' ) . add ( CatPW. surl, { 'date' : Dates ( ) , 'id' : CatPW. surl, 'exp' : $. now ( ) + StorageExp* 24 * 60 * 60 * 1000 } ) ;
}
} ) ;
if ( CatPW. unPW&& ! localStorage[ CatPW. surl] ) {
StorageDB ( CatPW. surl) . insert ( CatPW) ;
StorageDB ( 'ShareIDexp' ) . add ( CatPW. surl, { 'date' : Dates ( ) , 'id' : CatPW. surl, 'exp' : $. now ( ) + StorageExp* 24 * 60 * 60 * 1000 } ) ;
}
if ( 'Share_' + yunData. surl== CatPW. surl && localStorage[ CatPW. surl] ) {
var CatPW_Info= $ ( ''
) . attr ( 'id' , 'CatPW_Info' ) . text ( '提取码:' + CatPW
. sCode
+ ' ' + '解压密码:' ) ;
var CatPW_Info_unPW
= $ ( ' ' ) . attr ( { 'id' : 'unPW' , 'title' : '点击复制密码,修改内容将被保存' } ) . css ( { 'margin' : '0 10px' , 'width' : '150px' , 'text-align' : 'center' } ) . val ( CatPW
. unPW
) . change ( function ( ) {
StorageDB ( CatPW
. surl
) . add ( 'unPW' , encodeURIComponent ( this . value
) ) ;
CatPW
. unPW
= encodeURIComponent ( this . value
) ;
GM_setValue ( 'CatPW' , CatPW
) ;
} ) . click ( function ( ) {
document
. execCommand ( "SelectAll" ) ; document
. execCommand ( "copy" ) ;
} ) ;
var CatPW_Info_delBtn
= $ ( '' ) . text ( '删除记录' ) . val ( '删除记录' ) . click ( function ( ) {
delete localStorage
[ CatPW
. surl
] ;
StorageDB ( 'ShareIDexp' ) . del ( CatPW
. surl
) ;
GM_setValue ( 'CatPW' , CatPW_Format
) ;
this . disabled
= true ;
} ) ;
var CatPW_Info_WebTitle
= $ ( '' ) . attr ( { 'id' : 'CatPW_webTitle' } ) . text ( '网页标题:' + CatPW. webTitle) ;
var CatPW_Info_WebSrc= $ ( '' ) . attr ( { 'id' : 'CatPW_webSrc' , 'href' : CatPW. webSrc, 'target' : 'blank' } ) . text ( '网盘来源:' + CatPW. webSrc) ;
GM_addStyle ( '#CatPW_Info{font-size:14px;border:1px solid #06c;padding:5px;display:block;}' ) ;
CatPW_Info. append ( CatPW_Info_unPW, CatPW_Info_delBtn, ' ' , CatPW_Info_WebTitle, ' ' , CatPW_Info_WebSrc) ;
UpdataConfig. MessageUI? CatPW_Info. insertBefore ( '.module-share-header' ) : Fn_MessageUI ( CatPW_Info) ;
}
StorageDB ( 'ShareIDexp' ) . deleteExpires ( ) ;
}
} ,
init : function ( ) {
this . CatPW_Manage ( ) ;
this . ShowInfo ( ) ;
}
} ;
CatPW_BaiduPan. init ( ) ;
console. groupEnd ( ) ;
}
} ,
'eyun.baidu.com' : {
chk: /^[a-z0-9]{4}$/ ,
code: '.share-access-code' ,
btn: '.g-button-right' ,
pwdRule : /(?:提取|访问)[码碼]?\s*[:: ]?\s*([a-z\d]{4,14})/ ,
codeRule : /(?:(?:提取|访问|密[码碼]|Extracted-code)[码碼]?)\s*[:: ]?\s*([a-z\d]{4,14})/i ,
PreProcess: function ( ) {
if ( ( hash&& ! /sharelink|path/i . test ( hash) ) && ! /enterprise/ . test ( paths) ) {
location. href= location. href. replace ( location. hash, '' ) ;
}
conf. ShareUK= yunData. SHARE_UK || getQueryString ( 'uk' ) ;
conf. ShareID= yunData. SHARE_ID || getQueryString ( 'cid' ) ;
conf. sCode= /^#/ . test ( hash) ? hash. match ( /^#(\w+)&?/ ) [ 1 ] : StorageDB ( conf. ShareID) . find ( 'sCode' ) ;
$ ( conf. btn) . click ( function ( ) {
if ( ! localStorage[ conf. ShareID] && conf. sCode) {
StorageDB ( conf. ShareID) . insert ( { 'sCode' : conf. sCode} ) ;
StorageDB ( 'ShareIDexp' ) . add ( conf. ShareID, { 'id' : conf. ShareID, 'exp' : $. now ( ) + StorageExp* 24 * 60 * 60 * 1000 } ) ;
}
} ) ;
StorageDB ( 'ShareIDexp' ) . deleteExpires ( ) ;
}
} ,
'yunpan.360.cn' : {
chk : /^[a-z0-9]{4,8}$/ ,
code : '.pwd-input' ,
btn : '.submit-btn'
} ,
'pan.lanzou.com' : {
chk : /^[a-z0-9]{4,8}$/ ,
code : '#pwd' ,
btn : '#sub'
} ,
'lanzous.com' : {
chk : /^[a-z0-9]{4,8}$/ ,
code : '#pwd' ,
btn : '#sub' ,
preSubmit : function ( codebox, cdoebtn, sCode) {
$ ( '.ifr2' ) . contents ( ) . find ( codebox) . val ( sCode) ;
$ ( '.ifr2' ) . contents ( ) . find ( cdoebtn) . click ( ) ;
}
} ,
'share.weiyun.com' : {
chk: /^[a-z0-9]{6}$/i ,
code: '.input-txt' ,
btn: '.btn.btn-l.btn-main' ,
pwdRule : /(?:提取|访问)[码碼]?\s*[:: ]?\s*([a-z\d]{4,6})/ ,
codeRule : /(?:(?:提取|访问|密[码碼]|Extracted-code)[码碼]?)\s*[:: ]?\s*([a-z\d]{4,6})/i ,
preSubmit: function ( codebox, cdoebtn, sCode) {
console. log ( '微云特殊提交方法' ) ;
$ ( codebox) . val ( sCode) ;
console. log ( $ ( codebox) . get ( 0 ) ) ;
if ( typeof ( InputEvent) !== 'undefined' ) {
$ ( codebox) . get ( 0 ) . dispatchEvent ( new InputEvent ( "input" ) ) ;
} else if ( KeyboardEvent) {
$ ( codebox) . get ( 0 ) . dispatchEvent ( new KeyboardEvent ( "input" ) ) ;
}
$ ( cdoebtn) . click ( ) ;
}
} ,
'dufile.com' : {
PreProcess: function ( ) {
if ( /\/down\// . test ( location. pathname) ) {
var hiddenProperty = 'hidden' in document ? 'hidden' :
'webkitHidden' in document ? 'webkitHidden' :
'mozHidden' in document ? 'mozHidden' :
null ;
var visibilityChangeEvent = hiddenProperty. replace ( /hidden/i , 'visibilitychange' ) ;
var onVisibilityChange = function ( ) {
if ( ! document[ hiddenProperty] ) {
document. title= '被发现啦(*´∇`*) 快来输验证码!' ;
} else {
alert ( 'DuFile 快来输验证码!' ) ;
}
}
document. addEventListener ( visibilityChangeEvent, onVisibilityChange) ;
}
}
} ,
'fxpan.com' : {
PreProcess: function ( ) {
var Key= $ ( '#key' ) . val ( ) ;
var CatPW= { 'date' : Dates ( ) , 'sCode' : '' , unPW: '' , 'Src' : '' , 'Hash' : '' , "webSrc" : '' , "webTitle" : '' } ;
var CatPW_Data= ( GM_getValue ( 'CatPW' ) != ( 'undefined' ) || GM_getValue ( 'CatPW' ) !== undefined) ? GM_getValue ( 'CatPW' ) : GM_setValue ( 'CatPW' , CatPW) ;
if ( CatPW_Data[ 'webSrc' ] . search ( Key) > - 1 ) {
var $CatPW_Info= $ ( ''
) . attr ( 'id' , 'CatPW_Info' ) ;
var $CatPW_Info_unPW
= $ ( ''
) . text ( '解压密码:' ) . append ( $ ( ' ' ) . attr ( { 'id' : 'unPW' , 'title' : '点击复制密码' } ) . css ( { 'margin' : '0 10px' , 'width' : '150px' , 'text-align' : 'center' } ) . val ( decodeURIComponent ( CatPW_Data
. unPW
) ) . click ( function ( ) { document
. execCommand ( "SelectAll" ) ; document
. execCommand ( "copy" ) ; } ) ) ;
var $CatPW_Info_title
= $ ( '' ) . attr ( { 'id' : 'CatPW_webTitle' } ) . text ( '网页标题:' + decodeURIComponent ( CatPW_Data. webTitle) ) ;
var $CatPW_Info_webSrc= $ ( '' ) . attr ( { 'id' : 'CatPW_webSrc' , 'href' : decodeURIComponent ( CatPW_Data. webSrc) , 'target' : 'blank' } ) . text ( '网盘来源:' + decodeURIComponent ( CatPW_Data. webSrc) ) ;
$CatPW_Info. append ( $CatPW_Info_unPW, ' ' , $CatPW_Info_title, ' ' , $CatPW_Info_webSrc) . insertBefore ( '.file_item.file_desc' ) ;
$ ( '.ysbtn' ) . click ( function ( ) {
StorageDB ( Key) . insert ( CatPW_Data) ;
StorageDB ( ) . insert ( CatPW_Data) ;
} ) ;
}
GM_addStyle ( '#CatPW_Info{font-size:14px;border:1px solid #06c;padding:5px;display:block;}' ) ;
}
} ,
'cloud.189.cn' : {
chk: /^[a-z0-9]{4}$/i ,
code: '#code_txt' ,
btn: '.btn.btn-primary' ,
PreProcess: function ( code, btn) {
document. querySelector ( '.btn-primary' ) . click ( ) ;
}
} ,
'yunfile.com' : {
PreProcess: function ( ) {
var FileID= getQueryString ( 'fileId' , $ ( '#counter_js' ) . attr ( 'src' ) ) ;
DiskInfo ( FileID, '.file_message' , function ( CatPW_Data, Key) {
CatPW_Data. FileID= FileID;
} ) ;
$ ( 'img[src="http://www.yunfile.com/images/premium-zh_cn.png"]' ) . hide ( ) ;
$ ( 'table.intro_text>tbody>tr:not(:nth-child(1)):not([style="height: 60px;"])' ) . hide ( ) ;
$ ( '#MemberPayfor' ) . hide ( ) ;
$ ( '#right_prem' ) . parent ( ) . hide ( ) ;
}
} ,
'ccchoo.com' : {
PreProcess: function ( ) {
String. prototype. isSearch = function ( key) {
return this . search ( key) > - 1 ;
}
if ( paths. isSearch ( 'file-' ) ) $ ( 'div[class="lo_box box_shadow"], div.down_two>.clearfix:nth-of-type(1), div.down_two>.down_tl, ul.down_three, div.down_five, div.down_six_main_b_img' ) . remove ( ) ;
$ ( 'img[src="http://www.ccchoo.com/images/ad2.gif"], .lo_box.box_shadow' ) . remove ( ) ;
DiskInfo ( paths. replace ( /\/(?:down2?|file)-(\d+).html/i , '$1' ) , '.down_one, .ksk' ) ;
GM_addStyle ( '.b-box{height:auto!important;display:block!important;}' ) ;
if ( paths. isSearch ( 'down2-' ) ) {
location. href= location. href. replace ( 'down2' , 'down' ) ;
} else if ( paths. isSearch ( 'down-' ) ) {
$ ( '#down_box, #down_boxc' ) . insertBefore ( '.ksk' ) . show ( ) ;
$ ( '#code_box, .ksk' ) . hide ( ) ;
}
}
} ,
'own-cloud.cn' : {
chk: /^[a-z0-9]{4,6}$/i ,
pwdRule : /(?:提取|访问)[码碼]?\s*[:: ]?\s*([a-z\d]{4,6})/ ,
codeRule : /(?:(?:提取|访问|密[码碼]|Extracted-code)[码碼]?)\s*[:: ]?\s*([a-z\d]{4,6})/i ,
code: '#inputPassword' ,
btn: '#submit_pwd'
}
} ,
'JumpUrl' : {
'zhihu.com' : {
href: $ ( 'A[href*="//link.zhihu.com/?target="]' ) ,
url: /.*\/\/link\.zhihu\.com\/\?target=/
} ,
'sijihuisuo.club' : {
href: $ ( '.down-tip A[href^="https://www.sijihuisuo.club/go/?url="]' ) ,
url: 'https://www.sijihuisuo.club/go/?url='
} ,
'nyavo.com' : {
href: $ ( '.content a' ) ,
url: 'https://www.nyavo.com/go?url='
}
} ,
'Support' : {
'agefans.tv' : {
path: /detail/i ,
callback: function ( ) {
$ ( '.res_links_a' ) . each ( function ( ) {
var res_links_a = this ;
GM_xmlhttpRequest ( {
method: "get" ,
url: res_links_a. href,
onload: function ( result) {
console. log ( 'load:' , res_links_a. href, result. finalUrl, result) ;
console. log ( res_links_a) ;
$ ( res_links_a) . attr ( { 'href' : result. finalUrl} ) ;
}
} ) ;
} ) ;
}
} ,
'yunpanjingling.com' : {
path : /search/i ,
callback: function ( ) {
$ ( '.item' ) . each ( function ( ) {
var name= $ ( this ) . find ( '.name' ) . text ( ) . trim ( ) ;
var code= $ ( this ) . find ( '.code' ) . text ( ) || '' ;
var href= $ ( this ) . find ( '.name' ) . find ( 'a' ) ;
var referrer= $ ( this ) . find ( '.referrer' ) . find ( 'a' ) ;
referrer. attr ( 'href' , decodeURIComponent ( getQueryString ( 'url' , referrer. attr ( 'href' ) ) ) ) ;
href. attr ( 'href' , decodeURIComponent ( getQueryString ( 'url' , href. attr ( 'href' ) ) ) ) ;
if ( code) href. attr ( 'href' , href. attr ( 'href' ) + '#' + code) ;
href. click ( function ( ) {
var CatPW_Data= { 'date' : Dates ( ) , 'sCode' : code, unPW: '' , 'Src' : href. attr ( 'href' ) , 'Hash' : '#' + code, "webSrc" : referrer. attr ( 'href' ) , "webTitle" : encodeURIComponent ( name) } ;
sessionStorage[ 'CatPW_Data' ] = JSON . stringify ( CatPW_Data) ;
} )
} ) ;
}
} ,
'jiluhome.cn' : {
path: /./i ,
callback: function ( ) {
var PostID= $. getUrlParam ( 'p' , $ ( 'link[rel="shortlink"]' ) . attr ( 'href' ) ) ;
DownAjax ( 'http://www.jiluhome.cn/wp-content/plugins/erphpdown/download.php?postid=' + PostID, '#erphpdown-download' , function ( e) {
$ ( e) . find ( 'a[href*="download.php"]' ) . each ( function ( ) {
var target= this ;
$. ajax ( {
"url" : 'http://www.jiluhome.cn/wp-content/plugins/erphpdown/download.php?postid=' + PostID+ "&url=&key=1" ,
success: function ( d) {
target. href= d. match ( /window.location=\'([^']+?)\'/i ) [ 1 ] ;
}
} ) ;
} ) ;
$ ( '#erphpdown>center' ) . append ( e) ;
} ) ;
}
} ,
'dakashangche.com' : {
path: /\/sj\/\d/ ,
callback: function ( ) {
console. log ( '特殊支持' ) ;
$ ( '.down-tip>a[href*="du.acgget.com"]' ) . each ( function ( ) {
DownAjax ( this . href, '.panel-body' , function ( e) {
$ ( e) . appendTo ( $ ( '#paydown' ) ) ;
} ) ;
} ) ;
}
} ,
'appinn.com' : {
path: /\/[^\/]+\//i ,
callback: function ( ) {
console. log ( '特殊支持' ) ;
new PreHandle. VM ( ) ;
}
} ,
'meta.appinn.com' : {
path: /\/t\/[^/]+\//i ,
callback: function ( ) {
new PreHandle. VM ( ) ;
$ ( 'A[href*="pan.baidu.com"],A[href*="eyun.baidu.com"]' ) . each ( function ( ) {
$ ( this ) . data ( { 'url' : this . href} ) . click ( function ( e) {
location. href= $ ( this ) . data ( 'url' ) ;
} ) ;
} ) ;
}
} ,
'madsck.com' : {
path: /\/resource\/\d+/ ,
callback: function ( ) {
var ID = $ ( '.btn-download' ) . data ( 'id' ) ;
$. ajax ( {
"url" : "http://www.madsck.com/ajax/login/download-link?id=" + ID ,
method: "GET" ,
dataType: "json" ,
success: function ( e) {
var res= e. resource;
$ ( '.btn-download' ) . css ( 'display' , 'none' ) ;
$ ( '' ) . attr ( { 'href' : res. resource_link+ '#' + res. fetch_code, 'target' : 'blank' , 'class' : 'btn-download' } ) . css ( { 'line-height' : '60px' , 'text-align' : 'center' , 'font-size' : '24px' } ) . text ( '下载' ) . insertBefore ( '.btn-download' ) ;
}
} ) ;
}
} ,
'idanmu.com' : {
path : /storage\-download/i ,
callback : function ( ) {
$ ( '.input-group' ) . each ( function ( ) {
$ ( this ) . text ( $ ( this ) . text ( ) + $ ( this ) . find ( 'input' ) . val ( ) ) ;
} ) ;
}
} ,
'qiuquan.cc' : {
path: /./ ,
callback : function ( ) {
$ ( '#down>a[href*="pan.baidu.com"]' ) . each ( function ( ) {
if ( ! this . hash) {
this . hash= $ ( this ) . text ( ) . match ( /[\((](\w+)[)\)]/i ) [ 1 ] ;
}
} ) ;
}
} ,
'acg44.com' : {
path: /download/i ,
callback : function ( ) {
site[ 'codeRule' ] = /(?:(?:提取|访问|密[码碼])[码碼]?)\s*[:: ]?\s*([a-z\d]{4}|[^$]+)/i ;
addMutationObserver ( '#download-container' , function ( e) {
e. some ( function ( a) {
for ( var i in a. addedNodes) {
var b= a. addedNodes[ i] ;
if ( b. className== 'animated fadeIn' ) {
var VerCode= $ ( '[id^="downloadPwd"]' ) . val ( ) ;
var unZipPW= encodeURIComponent ( $ ( '[id^="extractPwd"]' ) . val ( ) ) ;
var DownUrl= $ ( '#download-container a.btn' ) . attr ( 'href' ) ;
if ( /pan.baidu.com\/share/i . test ( DownUrl) ) {
$ ( '#download-container a.btn' ) . attr ( 'href' , DownUrl+ '&unPW=' + unZipPW+ '&Src=' + encodeURIComponent ( urls) ) ;
} else {
$ ( '#download-container a.btn' ) . attr ( 'href' , DownUrl+ '#' + VerCode+ '&unPW=' + unZipPW+ '&Src=' + encodeURIComponent ( urls) ) ;
}
}
}
} ) ;
} ) ;
}
} ,
'reimu.net' : {
path: /archives/i ,
callback: function ( ) {
site[ 'codeRule' ] = /(?:(?:提取|访问|密[码碼])[码碼]?)\s*[:: ]?\s*([a-z\d]{4}|8酱)/i ;
}
} ,
'ccava.net' : {
path: /post/i ,
callback: function ( ) {
site[ 'codeRule' ] = /(?:(?:提取|访问|密[码碼])[码碼]?)\s*[:: ]?\s*([a-z\d]{4,8}|ccava)/i ;
}
} ,
'mebook.cc' : {
path: /download.php/i ,
callback: function ( ) {
$ ( 'a' ) . click ( function ( ) {
if ( this . hostname== 'cloud.189.cn' ) site[ 'codeRule' ] = /天翼云盘密码\s*[:: ]?\s*([a-z\d]{4,8})/i ;
else site[ 'codeRule' ] = /百度网盘密码\s*[:: ]?\s*([a-z\d]{4,8})/i ;
} ) ;
}
} ,
's-dm.com' : {
path: /./ ,
callback: function ( ) {
$ ( 'body' ) . on ( 'click' , 'a' , function ( ) {
if ( this . hostname== 'pan.baidu.com' ) this . hash= $ ( this ) . text ( ) . replace ( /.+(?:[集版]|无修)(\w{4,8})$/ , '$1' ) ;
} ) ;
}
} ,
'mikuclub.org' : {
path: /\d+/ ,
callback: function ( ) {
$ ( '.passw' ) . each ( function ( ) {
var dl= $ ( this ) . parent ( ) . next ( ) . find ( '.dl' ) ;
dl[ 0 ] . hash= this . value;
} ) ;
}
}
}
} ;
var HostToList= { } , HostToListArr= {
YunDisk : {
'yunfile.com' : [ '5xpan.com' , 'putpan.com' , 'pwpan.com' , 'skpan.com' , '5xpan.com' , 'yfdisk.com' , 'filemarkets.com' , 'tadown.com' , 'page2.dfpan.com' ] ,
'ccchoo.com' : [ 'chooyun.com' , 'wodech.com' , 'caihop.com' , 'caihoo.me' , 'caihoo.info' , 'caihoo.co' , 'caihoo.club' ] ,
} ,
Support : {
's-dm.com' : [ 'fodm.net' ] ,
'reimu.net' : [ 'blog.reimu.net' ] ,
'idanmu.com' : [ 'idanmu.co' , 'idanmu.ch' , 'idanmu.at' ]
}
}
for ( var key in HostToListArr) {
HostToList[ key] = { } ;
for ( var key_i in HostToListArr[ key] ) {
var key_host= HostToListArr[ key] [ key_i] ;
for ( var key_j= 0 ; key_j< key_host. length; key_j++ ) {
HostToList[ key] [ key_host[ key_j] ] = key_i;
}
}
}
if ( HostToList[ 'YunDisk' ] [ host] ) site[ 'YunDisk' ] [ host] = site[ 'YunDisk' ] [ HostToList[ 'YunDisk' ] [ host] ] ;
else if ( HostToList[ 'Support' ] [ host] ) site[ 'Support' ] [ host] = site[ 'Support' ] [ HostToList[ 'Support' ] [ host] ] ;
else if ( /yunpan.360.cn/ . test ( host) ) host= 'yunpan.360.cn' ;
var conf = site[ 'YunDisk' ] [ host] ;
var HostArr = [ ] ;
for ( var i in site[ 'YunDisk' ] ) HostArr. push ( i) ;
for ( var i in HostToList[ 'YunDisk' ] ) HostArr. push ( i) ;
var HostExp = new RegExp ( HostArr. join ( "|" ) , 'i' ) ;
if ( site[ 'JumpUrl' ] [ host] ) {
site[ 'JumpUrl' ] [ host] [ 'href' ] . each ( function ( ) {
$ ( this ) . attr ( { 'href' : decodeURIComponent ( $ ( this ) . attr ( 'href' ) . replace ( site[ 'JumpUrl' ] [ host] [ 'url' ] , '' ) ) , 'target' : 'blank' } ) ;
} ) ;
}
if ( conf&& ! /zhidao.baidu.com/i . test ( host) ) {
if ( conf. PreProcess) conf. PreProcess ( ) ;
var StorageCode = StorageDB ( 'Share_' + conf. surl) . find ( 'sCode' ) ,
HashCode = /^#/ . test ( hash) && ! /^#list\/path=/i . test ( hash) ? hash. match ( /^#([^&]+)&?/ ) [ 1 ] : '' ;
var sCode = ( StorageCode&& StorageCode== HashCode) || ! HashCode ? StorageCode : HashCode;
if ( ! sCode) {
console. log ( '没有 Key 或格式不对' ) ;
} else {
console. log ( '抓取到的提取码: %s' , sCode) ;
}
setTimeout ( function ( ) {
var codeBox = $ ( conf. code) ,
btnOk = $ ( conf. btn) ;
if ( conf. preSubmit) {
codeBox. val ( sCode) ;
btnOk. click ( ) ;
$ ( document) . ready ( function ( ) {
conf. preSubmit ( conf. code, conf. btn, sCode) ;
} ) ;
} else if ( codeBox. length> 0 ) {
codeBox. val ( sCode) ;
btnOk. click ( ) ;
}
} , 10 ) ;
} else {
var PreHandle= {
Text : function ( text) {
text= text? typeof ( text) == "string" ? text. trim ( ) : text. textContent. trim ( ) : null ;
text= text? text. replace ( '本帖隐藏的内容' , '' ) : null ;
text= text? text. replace ( /([\[【]?解[压壓]|[压壓][缩縮])密[码碼][\]】]?\s*[:: ]?(?: ?)\s*([a-z\d]{4}|[^\n]+)/ig , '' ) : null ;
return text;
} ,
Code : function ( obj) {
var text= this . Text ( obj) ;
if ( ! text) return ;
var pw= site[ 'pwdRule' ] . test ( text) ? text. match ( site[ 'pwdRule' ] ) [ 1 ] : site[ 'codeRule' ] . test ( text) ? text. match ( site[ 'codeRule' ] ) [ 1 ] : null ;
return pw;
} ,
Fusion : function ( target, obj) {
if ( ! target. hash) {
target. href+= '#' + this . Code ( obj) ;
}
} ,
VM : function ( ) {
var Link= $ ( 'A[href*="pan.baidu.com"],A[href*="eyun.baidu.com"]' ) ;
for ( i= 0 ; i< Link. length; i++ ) {
var LinkParent= $ ( Link[ i] ) . parent ( ) ;
var LinkParentHtml= LinkParent. html ( ) ;
if ( PreHandle. Code ( LinkParentHtml) ) Link[ i] . href+= '#' + PreHandle. Code ( LinkParentHtml) ;
}
} ,
PassWord : function ( CatPW_Data) {
if ( StorageSave) {
var unPWArr= [
/[^\w]password[:: ]?([^\n]+)/igm ,
/解压[:: ]?(\w+)/gm ,
/【解[压壓]密[码碼]】\s*[:: ]?\s*(\w+)/igm ,
/【解[压壓]密[码碼]】\s*[:: ]?\s*([^\r\n]+)/igm ,
/\[解[压壓]密[码碼]\]\s*[:: ]?\s*([a-z\d\.:/@]+)/igm ,
/ ( ? : 解[ 压壓] 密? [ 码碼] ) \s* [ : : ] ? \s* ( [ a- z\d\. : /@]+)(?!-)\b/igm ,
/(?:解[压壓]密?[码碼])(?:都?是|为)\s*[:: ]?\s*([\w\.:/@]+)[^$\r\n]/igm ,
/(?:解[压壓]密?[码碼])(?:都?是|为)\s*[:: ]?\s*([^\w]+)[^$\r\n]/igm ,
/ 【? 压缩密码】? \s* [ : : ] ? \s* ( [ ^ \n] + ) / igm,
/ 【? [ 資资] 源密[ 码碼] 】? : ( \w+ ) /
] ;
for ( i= 0 ; i< unPWArr. length; i++ ) {
var unPWTemp= unPWArr[ i] . exec ( document. body. innerText) || unPWArr[ i] . exec ( document. body. outerHTML. replace ( /\b\w+=['"]?[^'"]+['"]?/ig , '' ) ) || unPWArr[ i] . exec ( document. body. textContent) ;
if ( unPWTemp) {
console. log ( i, '规则:' + unPWArr[ i] , '解压密码提取:' + encodeURIComponent ( unPWTemp[ 1 ] ) , '所有结果:' + unPWTemp) ;
CatPW_Data. unPW= encodeURIComponent ( unPWTemp[ 1 ] ) ;
break ;
}
}
if ( sessionStorage[ 'CatPW_Data' ] ) GM_setValue ( 'CatPW' , JSON . parse ( sessionStorage[ 'CatPW_Data' ] ) ) ;
else GM_setValue ( 'CatPW' , CatPW_Data) ;
console. log ( 'GM_getValue' , GM_getValue ( 'CatPW' ) ) ;
}
} ,
EachSibling : function ( $parent, $target, pi, $sibling, $i, $max) {
console. group ( '=== 同级元素遍历模式 第 ' + pi+ ' 次 ===' ) ;
var dz_i= $i|| 1 , dz_maxParent = $max|| 5 , dz_sibling= 5 || $sibling, dz_parent= $parent;
while ( dz_i<= dz_maxParent) {
dz_i++ ;
var dz_si= 1 , dz_s= dz_parent. nextSibling;
while ( dz_si<= dz_sibling) {
if ( dz_s) {
if ( PreHandle. Code ( dz_s) ) {
PreHandle. Fusion ( $target, dz_s) ;
return ;
}
} else {
if ( PreHandle. Code ( dz_parent) ) {
PreHandle. Fusion ( $target, dz_parent) ;
return true ;
}
break ;
}
dz_si++ ;
dz_s= dz_s. nextSibling;
}
dz_parent= dz_parent. parentNode;
console. groupEnd ( '--- 普通父级遍历模式 ----' ) ;
}
console. groupEnd ( '=== 同级元素遍历模式 ===' ) ;
}
} ;
var SupportHost= site[ 'Support' ] [ host] ;
if ( SupportHost&& ( SupportHost[ 'path' ] ? SupportHost[ 'path' ] . test ( paths) : getQueryString ( SupportHost[ 'search' ] ) ) ) {
SupportHost. callback ( ) ;
}
$ ( 'body' ) . on ( 'click' , 'a' , function ( e) {
var target= this , CatPW_Data;
if ( site[ 'YunDisk' ] [ this . host. toLowerCase ( ) ] && site[ 'YunDisk' ] [ this . host. toLowerCase ( ) ] [ 'pwdRule' ] ) site[ 'pwdRule' ] = site[ 'YunDisk' ] [ this . host. toLowerCase ( ) ] [ 'pwdRule' ] , site[ 'codeRule' ] = site[ 'YunDisk' ] [ this . host. toLowerCase ( ) ] [ 'codeRule' ] ;
if ( HostExp. test ( this . href) ) {
if ( Control_newTag) this . target= 'blank' ;
CatPW_Data= { 'date' : Dates ( ) , 'sCode' : '' , unPW: '' , 'Src' : this . href, 'surl' : '' , 'Hash' : this . hash, "webSrc" : encodeURIComponent ( urls) , "webTitle" : encodeURIComponent ( document. title) } ;
if ( this . hash) {
console. log ( '密码已融合,跳过密码融合步骤' ) ;
if ( sessionStorage[ 'CatPW_Data' ] ) GM_setValue ( 'CatPW' , JSON . parse ( sessionStorage[ 'CatPW_Data' ] ) ) ;
else GM_setValue ( 'CatPW' , CatPW_Data) ;
PreHandle. PassWord ( CatPW_Data) ;
return ;
}
console. group ( ' ===== 网盘自动填写密码 密码融合 =====' ) ;
if ( $. getUrlParam ( 'mod' ) == 'viewthread' && $. getUrlParam ( 'tid' ) && $ ( '.showhide' ) . length> 0 || u. discuz_uid) {
if ( $ ( target) . next ( ) . hasClass ( "showhide" ) && PreHandle. Code ( target. nextElementSibling) ) {
console. log ( '论坛特殊兼容模式 - 从链接后隐藏内容中查找密码' ) ;
PreHandle. Fusion ( target, target. nextElementSibling) ;
}
}
if ( PreHandle. Code ( target) ) {
console. log ( '在当前超链接的对象中查找密码' ) ;
PreHandle. Fusion ( target, target) ;
} else if ( PreHandle. Code ( target. nextSibling) ) {
console. log ( '密码在超链接后面的兄弟元素中' ) ;
PreHandle. Fusion ( target, target. nextSibling) ;
} else if ( PreHandle. Code ( target. parentNode) ) {
console. log ( '从父对象中查找密码' ) ;
PreHandle. Fusion ( target, target. parentNode) ;
} else {
console. group ( '--- 普通父级遍历模式 ----' ) ;
var i = 0 ,
maxParent = 5 ,
parent = target,
$parent = parent;
while ( i< maxParent) {
i++ ;
parent = parent. parentNode;
console. log ( '遍历上级目录查找密码:' + i, parent) ;
if ( parent. tagName== "TR" ) {
if ( PreHandle. Code ( parent. nextElementSibling) ) {
parent= parent. nextElementSibling;
console. log ( '表格中查找密码成功!' , parent) ;
PreHandle. Fusion ( target, parent) ;
break ;
}
} else {
var EachSiblingResult= PreHandle. EachSibling ( $parent, target, i) ;
if ( EachSiblingResult) break ;
$parent= parent. parentNode;
if ( maxParent> 5 ) {
console. log ( '已超出遍历范围' ) ;
}
}
if ( parent== document. body) break ;
}
console. groupEnd ( '--- 普通父级遍历模式 ----' ) ;
}
CatPW_Data. Hash= this . hash;
PreHandle. PassWord ( CatPW_Data) ;
}
console. groupEnd ( ) ;
} ) ;
}
function addMutationObserver ( selector, callback, Kill) {
var watch = document. querySelector ( selector) ;
if ( ! watch) {
return ;
}
var observer = new MutationObserver ( function ( mutations) {
var nodeAdded = mutations. some ( function ( x) { return x. addedNodes. length > 0 ; } ) ;
if ( nodeAdded) {
callback ( mutations) ;
if ( Kill) {
console. log ( '停止' + selector+ '的监控' ) ;
observer. disconnect ( ) ;
}
}
} ) ;
observer. observe ( watch, { childList: true , subtree: true } ) ;
}
function getQueryString ( name, url) {
var reg, str;
url= url? url. match ( /[?#].*/ ) . toString ( ) : location. search;
if ( Array. isArray ( name) ) {
for ( var i in name) {
reg = new RegExp ( "(?:^|&)(" + name[ i] + ")=([^&]*)(?:&|$)" , "i" ) ;
str = url. substr ( 1 ) . match ( reg) ;
if ( str !== null ) return unescape ( str[ 2 ] ) ;
}
} else {
reg = new RegExp ( "(?:^|&)(" + name + ")=([^&]*)(?:&|$)" , "i" ) ;
str = url. substr ( 1 ) . match ( reg) ;
if ( str !== null ) return unescape ( str[ 2 ] ) ;
}
return null ;
}
function StorageDB ( collectionName) {
collectionName = collectionName ? collectionName : 'default' ;
var cache = localStorage[ collectionName] ? JSON . parse ( localStorage[ collectionName] ) : { } ;
return {
add : function ( name, value) {
cache[ name] = value;
localStorage. setItem ( collectionName, JSON . stringify ( cache) ) ;
} ,
del: function ( name) {
if ( name) {
console. log ( cache, cache[ name] ) ;
delete cache[ name] ;
localStorage. setItem ( collectionName, JSON . stringify ( cache) ) ;
} else {
localStorage. removeItem ( name) ;
}
} ,
insert: function ( obj) {
localStorage. setItem ( collectionName, JSON . stringify ( obj) ) ;
} ,
Updata : function ( name, obj, value) {
cache[ obj] = cache[ obj] || { } ;
cache[ obj] [ name] = value;
localStorage. setItem ( collectionName, JSON . stringify ( cache) ) ;
} ,
Query : function ( obj, name) {
return cache[ obj] ? name? ( cache[ obj] [ name] ? cache[ obj] [ name] : null ) : cache[ obj] : null ;
} ,
find : function ( name) {
if ( ! collectionName) return false ;
return cache[ name] ;
} ,
read : function ( ) {
return $. isEmptyObject ( cache) ? null : cache;
} ,
deleteExpires : function ( now) {
now= now|| $. now ( ) ;
for ( var i in cache) {
if ( now> cache[ i] [ 'exp' ] ) {
delete localStorage[ i] ;
this . del ( i) ;
}
}
}
} ;
}
function DiskInfo ( Key, target, Prepocess) {
var insertTarget= target,
CatPW_Data,
CatPW_Format= { 'date' : Dates ( ) , 'sCode' : '' , unPW: '' , 'Src' : '' , 'Hash' : '' , "webSrc" : '' , "webTitle" : '' } ;
if ( StorageDB ( Key) . read ( ) ) {
GM_setValue ( 'CatPW' , StorageDB ( Key) . read ( ) ) ;
CatPW_Data= StorageDB ( Key) . read ( ) ;
} else if ( GM_getValue ( 'CatPW' ) == 'undefined' || GM_getValue ( 'CatPW' ) === undefined) {
GM_setValue ( 'CatPW' , CatPW_Format) ;
} else {
CatPW_Data= GM_getValue ( 'CatPW' ) ;
}
if ( Prepocess) Prepocess ( CatPW_Data, Key) ;
if ( ( CatPW_Data[ 'Src' ] . search ( Key) > - 1 || CatPW_Data[ 'FileID' ] == Key) && $ ( '#CatPW_Info' ) . length< 1 ) {
var $CatPW_Info= $ ( ''
) . attr ( 'id' , 'CatPW_Info' ) ;
var $CatPW_Info_unPW
= $ ( ''
) . text ( '解压密码:' ) . append ( $ ( ' ' ) . attr ( { 'id' : 'unPW' , 'title' : '点击复制密码' } ) . css ( { 'margin' : '0 10px' , 'width' : '150px' , 'text-align' : 'center' } ) . val ( decodeURIComponent ( CatPW_Data
. unPW
) ) . click ( function ( ) { document
. execCommand ( "SelectAll" ) ; document
. execCommand ( "copy" ) ; } ) . change ( function ( ) {
StorageDB ( Key
) . add ( 'unPW' , encodeURIComponent ( this . value
) ) ;
CatPW_Data
. unPW
= encodeURIComponent ( this . value
) ;
GM_setValue ( 'CatPW' , CatPW_Data
) ;
} ) ) ;
var $CatPW_Info_title
= $ ( '' ) . text ( '网页标题:' ) . append ( $ ( ' ' ) . attr ( { 'id' : 'CatPW_webTitle' , 'title' : '内容修改自动保存' } ) . val ( decodeURIComponent ( CatPW_Data. webTitle) ) . css ( { 'margin' : '0 10px' , 'padding' : '0 2px' , 'min-width' : '450px' } ) . show ( function ( ) {
$ ( this ) . css ( { 'width' : this . value. length* 15 } ) ;
} ) . change ( function ( ) {
StorageDB ( Key) . add ( 'webTitle' , encodeURIComponent ( this . value) ) ;
} ) ) ;
var $CatPW_Info_webSrc= $ ( '' ) . attr ( { 'id' : 'CatPW_webSrc' , 'href' : decodeURIComponent ( CatPW_Data. webSrc) , 'target' : 'blank' } ) . text ( '网盘来源:' + decodeURIComponent ( decodeURIComponent ( CatPW_Data. webSrc) ) ) ;
var $CatPW_Info_DeleteBtn= $ ( '' ) . text ( '删除记录' ) . val ( '删除记录' ) . css ( { 'display' : 'inline-block' } ) . click ( function ( ) {
delete localStorage[ Key] ;
GM_setValue ( 'CatPW' , CatPW_Format) ;
this . disabled= true ;
} ) ;
$CatPW_Info. append ( $CatPW_Info_unPW. append ( $CatPW_Info_DeleteBtn) , ' ' , $CatPW_Info_title, ' ' , $CatPW_Info_webSrc) . insertBefore ( insertTarget) ;
StorageDB ( Key) . insert ( CatPW_Data) ;
} else {
$ ( ''
) . append ( '当前记录网盘地址为:' , $ ( '' ) . attr ( { 'href' : CatPW_Data
. Src
, 'target' : 'blank' } ) . text ( CatPW_Data
. Src
) , ' 与当前网盘不符' ) . insertBefore ( insertTarget
) ;
}
GM_addStyle ( '#CatPW_Info{font-size:14px;border:1px solid #06c;padding:5px;display:block;}' ) ;
}
function DownAjax ( urls
, selection
, callback
) {
GM_xmlhttpRequest ( {
method
: "GET" ,
url
: urls
,
onload
: function ( result
) {
var parsetext = function ( text
) {
var doc
= null ;
try {
doc
= document
. implementation
. createHTMLDocument ( "" ) ;
doc
. documentElement
. innerHTML
= text
;
return doc
;
}
catch ( e ) {
alert ( "parse error" ) ;
}
} ;
var Down
;
var doc
= parsetext ( result
. responseText
) ;
console
. log ( doc
, $ ( doc
) ) ;
var t
= $ ( doc
) . find ( selection
) ;
callback ( t
) ;
}
} ) ;
}
function Dates ( ) {
var sDate
= new Date ( ) ;
return sDate
. getFullYear ( ) + '/' + ( sDate
. getMonth ( ) + 1 ) + '/' + sDate
. getDate ( ) ;
}
function Fn_MessageUI ( content
) {
GM_addStyle ( `
#MessageUI {
width: 100%;
position: fixed;
left: 0;
top: 0;
z-index: 99999999;
pointer-events: none;
}
#MessageUI * {
pointer-events: auto;
}
#MessageUI_Btn {
position: relative;
margin: 0 auto;
padding: 1px 0;
width: 100px;
height: 16px;
color: #000;
font-size: 12px;
line-height: 10px;
cursor: pointer;
text-align: center;
border: 1px solid #AAA;
border-radius: 0 0 12px 12px;
background-color: #fff;
box-shadow: 0 0 5px rgba(0, 0, 0, .1);
}
#MessageUI_Btn:hover {
color: rgba(0, 0, 0, .8);
background-color: rgba(255, 255, 255, 0.8);
}
#MessageUI_Panel {
display: none;
border-top: 5px solid #65adff;
background-color: #FFF;
box-shadow: 0 0 5px rgba(0, 0, 0, .1);
}
#MessageUI_Panel > #MessageUI_Panel_Content {
display: flex;
flex: 1 1 none;
flex-wrap: wrap;
width: 100%;
max-width: 1400px;
margin: 0 auto;
padding: 16px 20px;
position: relative;
}
` ) ;
var MessageUI
= $ ( ''
) . attr ( { 'id' : 'MessageUI' } ) ,
MessageUI_Btn
= $ ( ''
) . attr ( { 'id' : 'MessageUI_Btn' } ) . text ( '展开网盘信息' ) ,
MessageUI_Panel
= $ ( ''
) . attr ( { 'id' : 'MessageUI_Panel' } ) ,
MessageUI_Panel_Content
= $ ( '') . attr ( { 'id' : 'MessageUI_Panel_Content' } ) ;
MessageUI. click ( function ( ele) {
var eleStyle = MessageUI_Panel. css ( 'display' ) ;
if ( MessageUI_Panel. css ( 'display' ) === 'none' ) {
MessageUI_Panel. css ( 'display' , 'block' ) ;
} else {
MessageUI_Panel. css ( 'display' , '' ) ;
}
} ) ;
MessageUI_Panel_Content. html ( content) ;
$ ( 'body' ) . after ( MessageUI. append ( MessageUI_Btn, MessageUI_Panel. append ( MessageUI_Panel_Content) ) ) ;
}