Advertisement
Guest User

cabecita

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