提取码自动填写

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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;
}