Greasy Fork

Greasy Fork is available in English.

KissAnime Auto Captcha

Auto complete KissAnime Captcha

当前为 2017-07-02 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         KissAnime Auto Captcha
// @namespace    http://greasyfork.icu/en/users/135934-elti-musa
// @version      2.0
// @description  Auto complete KissAnime Captcha
// @author       AnimeBro1
// @match        http://kissanime.ru/Special/AreYouHuman2*
// @grant        GM_setValue
// @grant        GM_getValue
// @require      http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// ==/UserScript==

var images = [];
var words = [];
var count = 0;
(function() {
    $("body").append('<div id="CaptchaInfo" style="display:none;width:200px;height:150px;font-size:20px;position:fixed; top: 10px; left:10px; background: red; border-radius: 25px;padding:40px;"><p></p></div>');
   //getE();
    //alert(GM_listValues());
    if(!isBasicJson()){
        getBasicJson();
    }
    document.getElementsByTagName("body")[0].onload = function(){
        var loaders = [];
        var x = $("[indexValue]").toArray();
        for(var i =0; i < 5; i++){
            getBase64Image(x[i]);
        }
        console.log(images);
        words = getWords();
        Complete();
    };
})();

function isBasicJson(){
    return GM_getValue("AnimeBro1",false);
}

function getBasicJson(){
    var isFirefox = typeof InstallTrigger !== 'undefined';
    var isChrome = !!window.chrome && !!window.chrome.webstore;
    $("#CaptchaInfo").show();
    $("#CaptchaInfo").find("p").html("First time running, fetching some files... Page will reload.");
    var msg='';
    if(isChrome){
        msg = $.ajax({type: "GET", url: "https://rawgit.com/Eltion/Kissanime-Chaptcha-Auto-Complete/master/BasicJson.json", async: false}).responseText;
    }else if(isFirefox){
         msg = $.ajax({type: "GET", url: "https://rawgit.com/Eltion/Kissanime-Chaptcha-Auto-Complete/master/BasicJsonFirefox.json", async: false}).responseText;
    }else{
        alert("Not FireFox or Chrome");
        msg = $.ajax({type: "GET", url: "https://rawgit.com/Eltion/Kissanime-Chaptcha-Auto-Complete/master/BasicJsonFireFox.json", async: false}).responseText;
    }
    msg = JSON.parse(msg);
    for(var i = 0; i < msg.length; i++){
        GM_setValue(msg[i].n,msg[i].v);
    }
    location.reload();
}
function getE(){
    var x = GM_listValues();
    var b = "";
    for(var i =0; i < x.length; i++){
        b += '{"n":"'+x[i]+'","v":"'+GM_getValue(x[i])+'"},';
    }
    $('body').html("<p>"+b+"</p>");
}
function getBase64Image(img) {
    var canvas = document.createElement("canvas");
    canvas.width = img.naturalWidth;
    canvas.height = img.naturalHeight;
    var ctx = canvas.getContext("2d");
    ctx.drawImage(img, 0, 0);
    var dataURL = canvas.toDataURL("image/jpeg");

    //dataURL = dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
    images.push(dataURL);
}

function getWords(){
    var words = $("#formVerify").find("span").toArray();
    var First = words[0].innerText;
    var Second = words[1].innerText;
    return [First, Second];
}

function Learn(){
    $("[indexValue]").on('click', function(){
        count++;
        var x = parseInt($(this).attr("indexValue"));
        if(GM_getValue(words[count-1],false) !== false){
            var nn = GM_getValue(words[count-1])+" "+images[x];
            GM_setValue(words[count-1],nn);
        }else{
            var gg = images[x];
            GM_setValue(words[count-1],gg);
        }
    });
}

function Complete() {
    var jj = 0;
    for(var j = 0; j <2; j++){
        var w1 = GM_getValue( words[j], false );
        if(w1 !== false){
            if(w1.includes(" ")){
                w1 = w1.split(" ");
            }else{
                w1 = [w1];
            }
            for(var k =0; k < w1.length; k++){
                for(var i = 0; i < images.length; i++){
                    if(images[i] === w1[k]){
                        $("[indexValue='"+i+"']").click();
                        jj++;
                        if(j === 0){
                            count++;
                        }
                    }
                }
            }
        }
    }
    UpdateTest(jj);
    Learn();
}

function UpdateTest(jj){
    if(jj === 0){
        $("#CaptchaInfo").show();
        $("#CaptchaInfo").find("p").html("Couldn't recognize the images. Please select them so script can learn them for next time. IMPORTANT ***Select them in order***");
    }else if(jj === 1){
        $("#CaptchaInfo").show();
        $("#CaptchaInfo").find("p").html("Only one of the images is recognized. Please select the other one so script can learn it for next time.");
    }
}