Greasy Fork

来自缓存

Greasy Fork is available in English.

Chiphell自动填充验证码

自动填充在Chiphell上发帖和回复时的第一个验证码

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Chiphell自动填充验证码
// @namespace    http://www.chiphell.com/
// @version      0.2
// @description  自动填充在Chiphell上发帖和回复时的第一个验证码
// @author       1461748123
// @include      http://www.chiphell.com/*
// @include      https://www.chiphell.com/*
// ==/UserScript==

window.addEventListener('load',
function() {
    fillCaptcha();
    checkCaptcha();
},
false);

function fillCaptcha() {
    var captcha = getCaptcha();
    var input = document.getElementsByName('secanswer')[0];
    input.value = input.defaultValue = captcha;
}

function checkCaptcha() {
    eval(document.getElementsByName('secanswer')[0].getAttribute("onblur"));
}

function getCaptcha() {
    var html = document.getElementsByClassName('p_pop p_opt')[0].innerHTML;
    var key = getKey(html);
    var secret = getSecret(html);
    return secret.substring(getCaptchaStartLocation(key), getCaptchaEndLocation(key)) + 'CHH';
}

function getKey(html) {
    var end = html.indexOf('位');
    return html.substring(56, end);
}

function getSecret(html) {
    var start = html.indexOf('CHH</b><br><b style=\"color:red;\">') + 33;
    var end = html.indexOf(' </b>');
    return html.substring(start, end).replace(/ /g, "");
}

function getCaptchaStartLocation(key) {
    var spacer = key.indexOf('-');
    return key.substring(0, spacer) - 1;
}

function getCaptchaEndLocation(key) {
    var spacer = key.indexOf('-');
    return key.substring(spacer + 1);
}