Greasy Fork is available in English.

网盘自动填写密码【增强版】

网盘自动填写提取密码【增强版】+网盘超链接与提取码融合。

ของเมื่อวันที่ 30-10-2015 ดู เวอร์ชันล่าสุด

// ==UserScript==
// @name 			网盘自动填写密码【增强版】
// @description		网盘自动填写提取密码【增强版】+网盘超链接与提取码融合。
// @authore			极品小猫
// @namespace   	http://www.cnblogs.com/hkmhd/
// @version			2.0.0
// 
// 支持的网盘
// @include     	http://pan.baidu.com/share/init?*
// @include     	http://yun.baidu.com/share/init?*
// @include     	http://www.kuaipan.cn/file/id_*
// @include     	http://*.yunpan.cn/lk/*
// @include     	http://vdisk.weibo.com/lc/*
// @include     	http://*
// @include			https://*
// 
// @exclude			/https?://www.baidu.com/(?:s|baidu)\?/
// @require			http://code.jquery.com/jquery-latest.js
// @grant			unsafeWindow
// @run-at			document-idle
// ==/UserScript==

var urls=location.href;
var hash=location.hash;
var host=location.hostname.replace(/^www\./i,'').toLowerCase();
unsafeWindow.eve = Event;

var site = {
	'yunpan.cn': {
		chk:  /^[a-z0-9]{4}$/,
		code: '.pwd-input',
		btn:  '.submit-btn'
	},
	'baidu.com': {
		chk:  /^[a-z0-9]{4}$/,
		code: '#accessCode',
		btn:  '#submitBtn'
	},
	'kuaipan.cn': {
		chk:  /^[a-z0-9]{6}$/i,
		code: '#pwdContaier .txt',
		btn:  '#btnOK',
		preSubmit: function (codeBox, okBtn) {
			$('#pwdContaier .bold').textContent = '请手动单击确认按钮然后刷新页面';
		}
	},
	'weibo.com': {
		chk:  /^[a-z0-9]{4}$/i,
		code: '#keypass',
		btn:  '.search_btn_wrap > a',
		preSubmit: function (codeBox, okBtn) {
			var $wt = $('.wrong_tips');
			if ($wt) {
				$wt.textContent += ';已禁用自动输入。';
				return true;
			}
			unsafeWindow.validate();
		}
	},
	'codeRule':/(?:提取码|密码)[:: ]?\s*([a-z\d]{4})/i
};

var hostName = location.host.match(/\w+\.\w+$/)[0].toLowerCase();
var conf = site[hostName];
var HostArr = [];for(var i in site) HostArr.push(i);var HostExp = new RegExp(HostArr.join("|"),'i');	//生成校验超链接的正则

if(conf){
	// 调试用,检查是否为合法格式
	if (!conf.chk.test(sCode)) {
		console.log('没有 Key 或格式不对');
	} else {
		console.log ('抓取到的提取码: %s', sCode);
	}

	// 抓取提取码
	var sCode = location.hash.slice(1).trim();

		// 加个小延时
		setTimeout (function () {
			// 键入提取码并单击「提交」按钮,报错不用理。
			var codeBox = $(conf.code),
				btnOk = $(conf.btn);

			codeBox.val(sCode);		//填写验证码
			
			if (conf.preSubmit)
				if (conf.preSubmit (codeBox, btnOk))
					return ;

			btnOk.click();
		}, 10);
} else {
	$('A').click(function(){
		//console.log(this.parentNode.textContent);
		if(HostExp.test(event.target.href)&&/(?:密码|提取码)/.test(event.target.textContent)){
			console.log('在当前超链接的对象中查找密码');
			var pw=event.target.textContent.match(site['codeRule'])[1];
			if(!/#/i.test(event.target.href)) event.target.href+='#'+pw;
		} else if(HostExp.test(event.target.href)&&site['codeRule'].test(event.target.parentNode.textContent)){
			console.log('从父对象中查找密码');
			if(!/#/i.test(event.target.href)) event.target.href+='#'+event.target.parentNode.textContent.match(site['codeRule'])[1];
		}
	})
}