Baidu Pan SuperKey

度盘万能钥匙,云盘万能钥匙扩展改成 GM 脚本

Od 19.06.2018.. Pogledajte najnovija verzija.

// ==UserScript==
// @name		Baidu Pan SuperKey
// @namespace	a@b.c
// @author		jasake
// @description	度盘万能钥匙,云盘万能钥匙扩展改成 GM 脚本
// @description	有需要的请使用原版扩展:https://addons.mozilla.org/zh-CN/firefox/addon/ypsuperkey/
// @include		https://pan.baidu.com/share/init?surl=*
// @include		https://pan.baidu.com/wap/init?surl=*
// @charset		UTF-8
// @version		0.2
// @grant		GM_xmlhttpRequest
// @run-at		document-end
// ==/UserScript==

if (location.hash && /^#([a-zA-Z0-9]{4})$/.test(location.hash)) return;

var url ='https://ypsuperkey.meek.com.cn/api/items/BDY-'
		+ location.href.match(/share\/init\?surl=((?:\w|-)+)/)[1] + '?access_key=4fxNbkKKJX2pAm3b8AEu2zT5d2MbqGbD&client_version=2018.8';

GM_xmlhttpRequest({
	method: 'GET',
	url: url,
	onload: function(xhr) {
		//console.log(xhr.responseText);
		var e = JSON.parse(xhr.responseText);
		document.querySelector('.pickpw dt, .access-box label[for=accessCode]').innerHTML +=  '<br>度盘万能钥匙:'
			+ (xhr.status == 200 ? xhr.statusText.fontcolor('blue') : (e.message + '服务器状态:' + xhr.statusText + '(' + xhr.status + ')').fontcolor('red'));//状态提示
		if (xhr.status == 200) {
			document.querySelector('.pickpw input[tabindex="1"], .access-box input#accessCode').value = e.access_code;//填写密码
			setTimeout(function(){document.querySelector('.pickpw a.g-button, .access-box a#getfileBtn').click();}, 3e3);//三秒后自动点击
		}
	}
});