// ==UserScript== // @name KissAnime/Cartoon Downloader // @namespace https://greasyfork.org/users/10036 // @version 0.65 // @description Download videos from the sites KissAnime.com, KissAsian.com and KissCartoon.com // @author Domination9987 // @icon http://kissanime.ru/Content/images/favicon.ico // @match http://kissanime.com/Anime/* // @match http://kissanime.ru/Anime/* // @match https://kissanime.ru/Anime/* // @match http://kissasian.com/Drama/* // @match http://kisscartoon.me/Cartoon/* // @match https://*.googlevideo.com/* // @match https://*.c.docs.google.com/* // @match http://kissanime.ru/Special/AreYouHuman* // @match http://kissanime.com/Special/AreYouHuman* // @match https://kissanime.ru/Special/hi // @match https://kissanime.ru/Special/AreYouHuman* // @license Creative Commons; http://creativecommons.org/licenses/by/4.0/ // @require http://code.jquery.com/jquery-1.11.0.min.js // @grant none // @downloadURL https://update.greasyfork.icu/scripts/25798/KissAnimeCartoon%20Downloader.user.js // @updateURL https://update.greasyfork.icu/scripts/25798/KissAnimeCartoon%20Downloader.meta.js // ==/UserScript== /* INFO This script contains four parts 1. The download bar handler 2. The series page handler 3. Handles iframe captcha 4. Handles iframe captcha redirect 5. Proxy frame (always episode 0) which provides the video handler frame/s 6. The downloading video handler << This is the google docs sites */ //Classes //A function that extends classes, usage: //object.prototype = Extend(object, base, extend); function Extend(object, base, extend){ extend = extend || {}; object.prototype = Object.create(base.prototype); for (var i in extend){ if (extend.hasOwnProperty(i)){ object.prototype[i] = extend[i]; } } object.prototype.constructor = object; return object.prototype; } function Interval(params){ this.params = params || {}; this.exec = 0; for (var key in this.params){ if (this.params.hasOwnProperty(key)){ this[key] = this.params[key]; } } processes.push(this); } Interval.prototype = { kill: function(remove){ clearInterval(this.interval); this.active = false; if (remove) processes.splice(processes.indexOf(this), 1); }, resume: function(){ this.exec = 0; this.make(); } }; function GetInterval(params){ Interval.call(this, params); this.killAll = true; this.make(); } GetInterval.prototype = Extend(GetInterval, Interval, { getCheck: function(){ if (window.remain[this.buttonId] !== this.lastRemain){ this.lastRemain = window.remain[this.buttonId]; return; } this.req.abort(); this.exec += 1; console.log("EXEC COUNT:", this.exec, (this.exec > 3)); console.log("DEBUG:", global_settings.debug, (global_settings.debug)); if (this.exec > 3 && global_settings.debug) { console.log("ATTEMPTING TO ERROR"); Error("(getCheck): Something went wrong with: "+this.iframeId+". This commonly occurs due to the captcha restraint. Fill in the 'Are you human' test and try again."+$captcha[0].outerHTML, function() { ResumeProcesses(); }, this); } else { var _this = this; this.req = $.get(this.newUrl, function(xhr){GetFromPage(xhr, _this.buttonId, _this.iframeId, _this, _this.index)}); } }, make: function(){ var _this = this; console.log("Setting with:", global_settings.errTimeout); this.interval = setInterval(function() { _this.getCheck() }, global_settings.errTimeout*1000); this.req = $.get(this.newUrl, function(xhr) { GetFromPage(xhr, _this.buttonId, _this.iframeId, _this, _this.index); }); } }); function iFrameInterval(params){ Interval.call(this, params); this.make(); } iFrameInterval.prototype = Extend(iFrameInterval, Interval, { make: function(){ $("#"+this.id).attr("src", $("#"+this.id).attr("realSrc")); var _this = this; this.interval = setInterval(function(){ _this.iframeCheck()}, global_settings.errTimeout*1000); }, changeSrc: function(){ $("#"+this.id).attr("src", "google.com"); var _this = this; setTimeout(function(){ $('#'+_this.id).attr("src", $('#'+_this.id).attr("realSrc"))}, 1500); }, iframeCheck: function(){ var exist = ($("#"+this.id).length > 0 && $("#"+this.id).attr("dead") !== "true"); //If it exists and requires checking if (this.exec > 4 && global_settings.debug && exist){ Error("(iframeCheck): Something went wrong with: \""+this.title+"\".
It probably isn't redirecting properly. This could be because of slow internet or slow servers. Try increasing the 'Error Timeout' amount in the settings to fix this", function() {
ResumeProcesses();
}, this);
} else if (this.exec <= 4){
(exist) ? this.changeSrc() : this.kill(true);
}
this.exec += 1;
}
});
//Misc functions
//Check if a function contains a string or an array of strings
//Input: