// ==UserScript==
// @icon http://pan.baidu.com/box-static/disk-system/images/favicon.ico
// @name 吾爱破解网盘激活&提取码自动补全
// @namespace 1649991905@qq.com
// @author 猎隼丶止戈、Space
// @description 激活吾爱破解论坛中的百度网盘链接,并自动补全提取码然后跳转到分享地址
// @match *://www.52pojie.cn/thread*
// @match *://pan.baidu.com/share/*
// @require https://cdn.bootcss.com/jquery/1.8.3/jquery.min.js
// @version 0.1.0.0
// @grant unsafeWindow
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
/***********************************************自定义CSS样式-开始**********************************************/
//换个好看的样式
//2018年10月16日
GM_addStyle('.my_baidu_link{padding:2px 2px;text-decoration: none !important;background: #fff!important;color: #00bfff!important;border: 1px solid #00bfff;border-radius: 6px;transition: .3s background linear,.2s color linear;}.my_baidu_link:hover{padding:2px 2px;text-decoration: none !important;background: #00bfff!important;color: #fff!important;border: 1px solid #00bfff;border-radius: 6px;transition: .3s background linear,.2s color linear;}');
/***********************************************表格CSS********************************************************/
GM_addStyle('.jzcount{background-position: 0 -240px !important;}.jzcount:hover{background-position: -40px -240px !important;}');
GM_addStyle('.my_baidu_link_table>tbody>tr>td, .my_baidu_link_table>tbody>tr>th, .my_baidu_link_table>tfoot>tr>td, .my_baidu_link_table>tfoot>tr>th, .my_baidu_link_table>thead>tr>td, .my_baidu_link_table>thead>tr>th {padding: 15px;line-height: 1.42857143;vertical-align: top;border: 1px solid #F5F5F5;text-align=center;color:#3F51B5 !important}');
GM_addStyle('.my_baidu_link_table>tbody>tr>td>a, .my_baidu_link_table>tbody>tr>th>a, .my_baidu_link_table>tfoot>tr>td>a, .my_baidu_link_table>tfoot>tr>th>a, .my_baidu_link_table>thead>tr>td>a, .my_baidu_link_table>thead>tr>th>a {color: #00bfff!important;text-decoration: none !important;}');
GM_addStyle('#pancount{font-size: 25px;font-weight: bold;line-height: 38px !important;color: #fff !important;border: 1px solid #00bfff;border-radius: 50px;background: #2196F3 !important;}')
GM_addStyle('.jzcount > .cloud__logo-del {position: relative;right: -10000px;border-right: 0 solid transparent;filter: drop-shadow(-10000px 0 #fff);}')
/***********************************************自定义CSS样式-结束**********************************************/
var location = self.location;
var location_pathname = location.pathname;
/***********************************************新建几个变量数组************************************************/
var Pancount = new Array();
var Panlink = new Array();
var Panpwd = new Array();
/**********************************************注入sweetalert2*************************************************/
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://cdn.bootcss.com/limonte-sweetalert2/7.28.5/sweetalert2.all.js";
document.body.appendChild(script);
/************************************************自定义函数-开始***********************************************/
/**
*
* 提取网盘链接中的密码
* str 要匹配的字符串
* rule 分割符
*/
var arrayTool = {
getSplit: function(str, rule) {
return str.split(rule);
},
getUbound: function(array) {
return (array[array.length - 1]).replace(/(^\s*)|(\s*$)/g, "");
},
length: function(array) {
return array.length;
}
};
/**
*
*渲染网盘链接为蓝链
*
*/
function activelink(re, nre) {
$('.plc').each(function(index, value) {
//已是蓝链
var link = ($(this).html()).match(nre);
if (link) {
var ss = $(this).html();
ss = ss.replace(nre, '$1" class="my_baidu_link"');
$(this).html(ss);
//渲染完毕存入数组
Pancount.push(link);
//提取码与网盘链接拼接
//解决https://greasyfork.org/zh-CN/forum/discussion/44150/x?locale=zh-CN
//2018年10月16日
var pattern = /(密|提取)码[::]?[ A-Za-z0-9]*/g;
var pass = ($(value).html()).match(pattern);
if (pass) {
$(value).find(".my_baidu_link").each(function(i, v) {
var passArray = arrayTool.getSplit(pass[i], ":");
if (passArray.length < 2) {
passArray = arrayTool.getSplit(pass[i], ":")
}
var o_href = $(v).attr("href");
var n_href = o_href + "#" + arrayTool.getUbound(passArray);
$(v).attr("href", n_href);
/********************************获取网盘数量、链接、密码,存入数组***********************************/
Panlink.push(o_href);
Panpwd.push(arrayTool.getUbound(passArray));
//Debug
console.log("URL = " + o_href + " ---- " + "提取码 = " + arrayTool.getUbound(passArray));
});
}
} else {
//非蓝链
link = ($(this).html()).match(re);
if (link) {
var ss = $(this).html();
// 此处//$1不知道为何加//
// ss = ss.replace(re, '<a target="_blank" href="//$1" class="my_baidu_link">$1</a>');
ss = ss.replace(re, '<a target="_blank" href="$1" class="my_baidu_link">$1</a>');
$(this).html(ss);
//渲染完毕存入数组
Pancount.push(link);
//提取码与网盘链接拼接
//解决https://greasyfork.org/zh-CN/forum/discussion/44150/x?locale=zh-CN
//2018年10月16日
var pattern = /(密|提取)码[::]?[ A-Za-z0-9]*/g;
var pass = ($(value).html()).match(pattern);
if (pass) {
$(value).find(".my_baidu_link").each(function(i, v) {
var passArray = arrayTool.getSplit(pass[i], ":");
if (passArray.length < 2) {
passArray = arrayTool.getSplit(pass[i], ":")
}
var o_href = $(v).attr("href");
var n_href = o_href + "#" + arrayTool.getUbound(passArray);
$(v).attr("href", n_href);
/********************************获取网盘数量、链接、密码,存入数组***********************************/
Panlink.push(o_href);
Panpwd.push(arrayTool.getUbound(passArray));
//Debug
console.log("URL = " + o_href + " ---- " + "提取码 = " + arrayTool.getUbound(passArray));
});
}
}
}
});
}
/**
*
*提取网盘链接中的密码
*
*/
var getCode = function(rule) {
var code = location.hash.slice(1, 5);
if ((rule || /([a-z\d]{4})/i.exec(code))) {
code = RegExp.$1;
} else code = null;
return code;
};
/************************************************自定义函数-结束***********************************************/
$(function() {
/****************************** 渲染网盘链接为蓝链 ********************************/
// 百度网盘蓝链
var re_baidu = /((?:https?:\/\/)?(?:yun|pan|eyun).baidu.com\/(?:s\/\w*(((-)?\w*)*)?|share\/\S*\d))/g;
var re_ex_baidu = /(href="https?:\/\/(yun|pan|eyun).baidu.com\/(?:s\/\w*(((-)?\w*)*)?|share\/\S*\d))/g;
activelink(re_baidu, re_ex_baidu);
// 蓝奏网盘蓝链
var re_lanzou = /((?:https?:\/\/)?(pan|www).lanzou(s)?.com\/(?:\w*|\d))/g;
var re_ex_lanzou = /(href="https?:\/\/(pan|www).lanzou(s)?.com\/(?:\w*|\d))/g;
activelink(re_lanzou, re_ex_lanzou);
// 360网盘蓝链
var re_360 = /((?:https?:\/\/)?yunpan.360.cn\/(?:\w*|\d))/g;
var re_ex_360 = /(href="https?:\/\/yunpan.360.cn\/(?:\w*|\d))/g;
activelink(re_360, re_ex_360);
/******************************新增按钮********************************************/
var alert_text = "";
var Panlink_counts = 0;
alert_text +='<table class="my_baidu_link_table">';
alert_text +='<thead>';
alert_text +='<tr>';
alert_text +='<th><b>#</b></th>';
alert_text +='<th><b>网盘链接</b></th>';
alert_text +='<th><b>密码</b></th>';
alert_text +='</tr>';
alert_text +='</thead>';
alert_text +='<tbody>';
for (Panlink_counts in Panlink) {
alert_text += '<tr><td>'+Panlink_counts+'</td><td><a target="_blank" href="' + Panlink[Panlink_counts] + '">' + Panlink[Panlink_counts] + '#' + Panpwd[Panlink_counts] + '</a></td><td>' + Panpwd[Panlink_counts] + '</td></tr>';
}
alert_text +='</tbody>';
alert_text +='</table>';
//debug
console.log("探测到网盘链接数量" + Pancount[0].length);
//console.log(alert_text);
unsafeWindow._ShowPanLinks = () => {
swal({
width: 650,
title: '探测到网盘链接数量:' + Pancount[0].length + '个',
type: 'info',
html: alert_text,
showCloseButton: true,
confirmButtonText: '确认'
});
}
$('#jz52top').prepend('<span><a id="pancount" title="探测到网盘链接数量:' + Pancount[0].length + '个" class="jzcount" href="javascript:void(0);" onclick="_ShowPanLinks();"><img class="cloud__logo-del" src="https://www.easyicon.net/api/resizeApi.php?id=1109682&size=36"></a></span>');
//百度网盘提取码自动补全
if (location_pathname.indexOf("/share/") != -1 && $('form input') != null) {
var code = getCode();
$('form input').val(code);
$('form a[title=提取文件]').click();
}
});
})();