NoKissReload [CAPTCHA SKIP]

Plays the next Episode without reloading the page

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

  1. // ==UserScript==
  2. // @name NoKissReload [CAPTCHA SKIP]
  3. // @version 0.19
  4. // @description Plays the next Episode without reloading the page
  5. // @author lolamtisch@gmail.com
  6. // @license Creative Commons; http://creativecommons.org/licenses/by/4.0/
  7. // @match http://kissanime.ru/Anime/*/*
  8. // @grant GM_xmlhttpRequest
  9. // @grant GM_getValue
  10. // @grant GM_setValue
  11. // @namespace https://greasyfork.org/users/92233
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. var realUrl = '';
  17. $( document ).ready(function() {
  18.  
  19. var nbShortcuts = GM_getValue( 'nbShortcuts', 0 );
  20.  
  21. function noscript(strCode){
  22. var html = $(strCode.bold());
  23. html.find('script').remove();
  24. return html.html();
  25. }
  26.  
  27. function getvideolink(url){
  28. var results = new RegExp('[\?&]' + 's' + '=([^&#]*)').exec(window.location.href);
  29. url += results[0];
  30. $.ajax({
  31. method: "GET",
  32. url: url,
  33. cache: false,
  34. success : function(data, textStatus, xmLHttpRequest){
  35. handleAjaxData(data, url);
  36. },
  37. error: function(data, textStatus, xmLHttpRequest){
  38. window.location.href = url;
  39. }
  40. });
  41. }
  42.  
  43. function handleAjaxData(data, url){
  44. if(data.includes("Are You Human")){
  45. console.log('Captcha');
  46. k = url;
  47. realUrl = url;
  48. capture(data);
  49. return;
  50. }
  51. //console.log(data);
  52. history.pushState({myTag: true}, '', url);
  53. try{
  54. videojs('my_video_1').currentTime("0");
  55. var newlinks = data.split('<select id="slcQualix">')[1].split('</select>')[0];
  56. var link = newlinks.split('"')[1].split('"')[0];
  57. try{
  58. $("#divFileName").html(data.split('divFileName">')[1].split('</div>')[0]);
  59. $("#divDownload").html("");
  60. var urlBefore = $('#my_video_1 video').attr('src');
  61. }catch(e){}
  62. if( $('#slcQualix').height() === null){
  63. $('#my_video_1').before('<select style="display: none;" id="slcQualix"></select>');
  64. }
  65. if( $('#slcQualix').html() === newlinks){
  66. window.location.href = url;
  67. }
  68. $('#slcQualix').html(newlinks);
  69. $("head").trigger( "click" );
  70. if($('#my_video_1').height() === null){
  71. window.location.href = url;
  72. }
  73. videojs('my_video_1').currentTime("0");
  74. $('#slcQualix').trigger("change");
  75. if(urlBefore === $('#my_video_1 video').attr('src')){
  76. SetPlayer(ovelWrap($('#slcQualix').val()));
  77. }
  78. }catch(e){
  79. console.log("error:",e);
  80. window.location.href = url;
  81. }
  82.  
  83. $("#btnPrevious").parent().css("display","initial");
  84. $("#btnNext").parent().css("display","initial");
  85. if($("#selectEpisode")[0].selectedIndex === 0) {
  86. $("#btnPrevious").parent().css("display","none");
  87. }
  88.  
  89. if($("#selectEpisode")[0].selectedIndex === $("#selectEpisode option").size()-1) {
  90. $("#btnNext").parent().css("display","none");
  91. }
  92. }
  93.  
  94. function nextE(){
  95. if(active+1 < link.length){
  96. getvideolink(window.location.href.split('/').slice(0,5).join('/')+'/'+link[active+1]);
  97. active++;
  98. $("#selectEpisode")[0].selectedIndex = active;
  99.  
  100. }
  101. }
  102.  
  103. function previosE(){
  104. if(active > 0){
  105. getvideolink(window.location.href.split('/').slice(0,5).join('/')+'/'+link[active-1]);
  106. active--;
  107. $("#selectEpisode")[0].selectedIndex = active;
  108.  
  109. }
  110. }
  111.  
  112. var link = [];
  113. var active = null;
  114. $("#selectEpisode option").each(function( index ) {
  115. link[index] = $(this).attr("value");
  116. if($("#selectEpisode").attr("value") == $(this).attr("value")){
  117. active = index;
  118. }
  119. });
  120.  
  121. if($("#btnPrevious").height() === null && $("#btnNext").height() !== null){
  122. $("#btnNext").parent().before('<a href="#!"><img id="btnPrevious" src="http://kissanime.ru/Content/images/previous.png" title="Previous episode" border="0"></a>&nbsp;&nbsp;');
  123. $("#btnPrevious").parent().css("display","none");
  124. }
  125.  
  126. if($("#btnNext").height() === null && $("#btnPrevious").height() !== null){
  127. $("#btnPrevious").parent().after('&nbsp;&nbsp;<a href="#!"><img id="btnNext" src="http://kissanime.ru/Content/images/next.png" title="Next episode" border="0"></a>');
  128. $("#btnNext").parent().css("display","none");
  129. }
  130.  
  131. $("#btnNext").parent().attr("href","#!").click(function(){
  132. nextE();
  133. });
  134.  
  135. $("#btnPrevious").parent().attr("href","#!").click(function(){
  136. previosE();
  137. });
  138.  
  139. $("#selectEpisode").unbind().change(function(){
  140. var before = window.location.href.split('/').slice(0,5).join('/')+'/';
  141. active = $("#selectEpisode")[0].selectedIndex;
  142. getvideolink(before+link[active]);
  143. });
  144.  
  145. document.onkeydown = function(evt) {
  146. evt = evt || window.event;
  147. if (evt.keyCode == 78) {
  148. if(nbShortcuts == 1){
  149. nextE();
  150. }
  151. }
  152. if (evt.keyCode == 66) {
  153. if(nbShortcuts == 1){
  154. previosE();
  155. }
  156. }
  157. };
  158.  
  159. if(nbShortcuts == 1){
  160. var check = 'checked';
  161. }else{
  162. var check = '';
  163. }
  164. $('.barContent').after('<input type="checkbox" id="nbShortcuts" '+check+' > Shortcuts ( n = next, b = back )');
  165. $('#nbShortcuts').change(function(){
  166. if($('#nbShortcuts').is(":checked")){
  167. nbShortcuts = 1;
  168. GM_setValue('nbShortcuts', 1);
  169. }else{
  170. nbShortcuts = 0;
  171. GM_setValue('nbShortcuts', 0);
  172. }
  173. });
  174.  
  175. //Rest of code based on KissAnime Multi Downloader
  176. //Author: Anime Bro1
  177. //url: https://greasyfork.org/en/scripts/31080-kissanime-multi-downloader
  178. var images = ["","","","",""];
  179. var words = [];
  180. var k = "";
  181. var eps = [];
  182. var epsName = [];
  183. var epsLinks = [];
  184. var failedLinks = [];
  185.  
  186. var count = 0;
  187. var failedCount = 0;
  188.  
  189. var start = "";
  190. var end = "";
  191. var isText = false;
  192. var isHTML = false;
  193. var isM3U8 = false;
  194. var quality = [];
  195. var failed = true;
  196.  
  197. var animebro;
  198. var max = 1;
  199.  
  200.  
  201. function capture(data){
  202. if(!isBasicJson()){
  203. getBasicJson();
  204. }
  205. getEP(data);
  206. }
  207.  
  208. function isBasicJson(){
  209. return GM_getValue("AnimeBro1",false);
  210. }
  211.  
  212. function getBasicJson(){
  213. var isFirefox = typeof InstallTrigger !== 'undefined';
  214. var isChrome = !!window.chrome && !!window.chrome.webstore;
  215. $("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>');
  216. $("#CaptchaInfo").show();
  217. $("#CaptchaInfo").find("p").html("First time running, fetching some files... Page will reload.");
  218.  
  219. var msg='';
  220. if(isChrome){
  221. msg = $.ajax({type: "GET", url: "https://rawgit.com/Eltion/Kissanime-Chaptcha-Auto-Complete/master/BasicJson.json", async: false}).responseText;
  222. }else if(isFirefox){
  223. alert("x");
  224. msg = $.ajax({type: "GET", url: "https://rawgit.com/Eltion/Kissanime-Chaptcha-Auto-Complete/master/BasicJsonFirefox.json", async: false}).responseText;
  225. }else{
  226. alert("Not FireFox or Chrome");
  227. msg = $.ajax({type: "GET", url: "https://rawgit.com/Eltion/Kissanime-Chaptcha-Auto-Complete/master/BasicJsonFireFox.json", async: false}).responseText;
  228. }
  229. msg = JSON.parse(msg);
  230. for(var i = 0; i < msg.length; i++){
  231. GM_setValue(msg[i].n,msg[i].v);
  232. }
  233. location.reload();
  234. }
  235.  
  236. function getEP(data){
  237. var msg = data;
  238. words = [];
  239. images=["","","","",""];
  240. GetWords(msg,function(){
  241. getImages(msg,function(){
  242. /*count++;
  243. if(count < eps.length){
  244. getEP(eps[count]);
  245. }else{
  246. setTimeout(function(){
  247. AllDone();
  248. }, 5000);
  249. }*/
  250. });
  251. });
  252. }
  253.  
  254. function GetWords(html,callback){
  255. var form = html.split("formVerify")[1].split("</form")[0];
  256. var x = form.match(/(?:<span[^>]*>\s*)([^<]*)/g);
  257. var word1 = x[0].split(">")[1].replace(/\s\s/g,"");
  258. var word2 = x[1].split(">")[1].replace(/\s\s/g,"");
  259. words = [word1,word2];
  260. callback();
  261. }
  262.  
  263. function getImages(html,callback){
  264. //console.log(html);
  265. var items = html.match(/CapImg\?f=[^"']*/g);
  266. //console.log(items);
  267. loader(items, loadImage, function () {
  268. Complete();
  269. callback();
  270. });
  271. }
  272.  
  273. function Complete() {
  274. var jj = 0;
  275. var postData = "";
  276. for(var j = 0; j <2; j++){
  277. var w1 = GM_getValue( words[j], false );
  278. if(w1 !== false){
  279. if(w1.includes(" ")){
  280. w1 = w1.split(" ");
  281. }else{
  282. w1 = [w1];
  283. }
  284. for(var k =0; k < w1.length; k++){
  285. for(var i = 0; i < images.length; i++){
  286. if((images[i] === w1[k]) && postData.length < 4){
  287. postData += i+",";
  288. }
  289. }
  290. }
  291. }
  292. }
  293. if(postData.length == 4){
  294. postdata(postData);
  295. console.log("EP Grabed");
  296. }else{
  297. window.location.href = realUrl;
  298. }
  299. }
  300.  
  301. function postdata(answer){
  302. var data = {reUrl: k, answerCap: answer};
  303. var msg = $.ajax({type: "POST", url: "http://kissanime.ru/Special/AreYouHuman2",data: data ,async: false}).responseText;
  304. //console.log(msg);
  305. //alert();
  306. handleAjaxData(msg, k);
  307. //getLinks(msg);
  308. }
  309.  
  310. function loader(items, thingToDo, allDone) {
  311. if (!items) {
  312. // nothing to do.
  313. return;
  314. }
  315.  
  316. if ("undefined" === items.length) {
  317. // convert single item to array.
  318. items = [items];
  319. }
  320.  
  321. var count1 = items.length;
  322.  
  323. // this callback counts down the things to do.
  324. var thingToDoCompleted = function (items, i) {
  325. count1--;
  326. if (0 === count1) {
  327. allDone(items);
  328. }
  329. };
  330.  
  331. for (var i = 0; i < items.length; i++) {
  332. // 'do' each thing, and await callback.
  333. thingToDo(items, i, thingToDoCompleted);
  334. }
  335. }
  336.  
  337. function loadImage(items, i, onComplete) {
  338. var img = new Image();
  339. var canvas = document.createElement("canvas");
  340. var ctx = canvas.getContext("2d");
  341. var dataURL ="";
  342. var onLoad = function (e) {
  343. canvas.width = img.naturalWidth;
  344. canvas.height = img.naturalHeight;
  345. ctx.drawImage(img, 0, 0);
  346. dataURL = canvas.toDataURL("image/jpeg");
  347. images[i] = dataURL;
  348. e.target.removeEventListener("load", onLoad);
  349. onComplete(items, i);
  350. };
  351. img.addEventListener("load", onLoad, false);
  352. img.src = "http://kissanime.ru/Special/"+items[i];
  353. }
  354.  
  355. });
  356.  
  357. })();