提取码自动填写

访问分享链接时自动填写提取码并提交

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        提取码自动填写
// @author      billypon
// @description 访问分享链接时自动填写提取码并提交
// @version     1.0.6
// @namespace   http://www.canaansky.com/
// @match       *://pan.baidu.com/share/*
// @match       *://pan.baidu.com/s/*
// @run-at      document-idle
// @grant       none
// ==/UserScript==

var code = location.hash.slice(1,5);
if (!code)
	return;
console.debug("code", code);

function fill(input, button) {
	var input = document.querySelector(input), button = document.querySelector(button);
	if (input && button) {
		console.debug("elements", input, button);
		input.value = code;
		button.click();
	}
}

var domain = location.hostname.match(/\w+\.\w+$/)[0];
console.debug("domain", domain);
switch (domain) {
	case "baidu.com":
		fill(".pickpw input", ".pickpw .g-button");
		break;
}