// ==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: OR //The array uses OR operators String.prototype.contains = function(search){ var str = this; var bool = false; if (Object.prototype.toString.call(search) === '[object Array]'){ for (i = 0; i 1) return true; } return bool; }; //Reduce a string with double/triple spaces with single spaces String.prototype.singleSpace = function(){ var array = this.split(" "); for (var i = 0; i", {style:"border:0;width:100%;overflow:hidden;height:200px", seamless:true, src:linkSplit[0]+"."+linkSplit[1].split("/")[0]+'/Special/AreYouHuman?reUrl=hi', class:'captcha'}); function GetDecryption(){ var decryption = (window.location.href.contains("kissanime")) ? "asp" : "kissenc"; $kissenc = (window.$kissenc) ? $kissenc : {}; asp = (window.asp) ? asp : {}; var obj = { decryptName:(decryption === "kissenc") ? "kissenc.min.js" : "asp.js", decryptFunc:(decryption === "kissenc") ? $kissenc.decrypt : asp.wrap } return obj; } //------------------------------------------------------------------ PART I -------------------------------------------------------------------------------------*/ if (currentWindow === "episode"){ //Fix styling $("#selectPlayer option").each(function(){ $(this).html($(this).html().replace("(lightweight, mobile supported)", "").replace("(not recommended)", "")); }); $('#switch').parent().children().css('width', 'auto'); $('#switch').html($('#switch').html().replace("Turn off the light", "Off")); MakeBar('episode'); //Code here for local download links!!! $("#divDownload").html("Download video: "); var first = true; $("#selectQuality option").each(function(){ (first) ? first = false : $("#divDownload").html($("#divDownload").html() + " - "); var cQuality = parseInt($(this).text().replace("p", "")); //note the use of a local variable $("#divDownload").append($("", {html:cQuality+"p", class:"downloadLink pointer"})); }); $(document).on("click", ".downloadLink", function(){ DownloadCurrent($(this).text().replace("p", "")); }); //------------------------------------------------------------------ PART II -------------------------------------------------------------------------------------*/ } else if (currentWindow === "series"){ var decryption = GetDecryption(); var initialiseBar = function(seriesCounter, MakeBar) { seriesCounter = 0; MakeBar("series"); } var decryption = GetDecryption(); if (decryption.decryptName === 'kissenc.min.js') { // kissenc.min.js requires CryptoJS $.getScript("/scripts/aes.js").then(function(){ // Also requires sha256 return $.getScript("/scripts/sha256.min.js"); }).then(function(){ // This script is required for decryption of the links return $.getScript("/scripts/"+decryption.decryptName); }).then(function(){ initialiseBar(window.seriesCounter, MakeBar); }).fail(function(xhr, settings, exception){ console.error("Error in loading decryption script", decryption, exception); }); } else { // Only requires this script for decryption of the links $.getScript("/scripts/"+decryption.decryptName, function(){ initialiseBar(window.seriesCounter, MakeBar); }).fail(function(jqxhr, settings, exception){ console.error("error in loading decryption script", decryption, exception); }); } window.SeriesAfter = function(){ $("#multSelect").change(function(){ //A handler for the changing of the first episode to download var amount = parseInt($("#multSelect option").length) - parseInt($("#multSelect").val(), 10); if ($("#multAmount option").length > amount){ if ($("#multAmount").val() > amount) $("#multAmount").val(amount); $("#multAmount option:gt("+amount+")").remove(); //removes excess } var count = $("#multAmount option").length; for (var i = count; i<=amount; i++){ $("#multAmount").append($("