NoKissReload

Plays the next video without reloading the page

当前为 2017-03-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name NoKissReload
  3. // @version 0.14
  4. // @description Plays the next video 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. // @namespace https://greasyfork.org/users/92233
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. $( document ).ready(function() {
  15.  
  16. function noscript(strCode){
  17. var html = $(strCode.bold());
  18. html.find('script').remove();
  19. return html.html();
  20. }
  21.  
  22. function getvideolink(url){
  23. url += "&s=beta";
  24. $.ajax({
  25. method: "GET",
  26. url: url,
  27. cache: false,
  28. success : function(data, textStatus, xmLHttpRequest){
  29. //console.log(data);
  30. history.pushState({myTag: true}, '', url);
  31. try{
  32. var newlinks = data.split('<select id="slcQualix">')[1].split('</select>')[0];
  33. var link = newlinks.split('"')[1].split('"')[0];
  34. try{
  35. $("#divFileName").html(data.split('divFileName">')[1].split('</div>')[0]);
  36. $("#divDownload").html("");
  37. var urlBefore = $('#my_video_1 video').attr('src');
  38. }catch(e){}
  39. if( $('#slcQualix').height() === null){
  40. $('#my_video_1').before('<select style="display: none;" id="slcQualix"></select>');
  41. }
  42. if( $('#slcQualix').html() === newlinks){
  43. window.location.href = url;
  44. }
  45. $('#slcQualix').html(newlinks);
  46. $("head").trigger( "click" );
  47. if($('#my_video_1').height() === null){
  48. window.location.href = url;
  49. }
  50. videojs('my_video_1').currentTime("0");
  51. $('#slcQualix').trigger("change");
  52. if(urlBefore === $('#my_video_1 video').attr('src')){
  53. SetPlayer(ovelWrap($('#slcQualix').val()));
  54. }
  55. }catch(e){
  56. console.log("error:",e);
  57. window.location.href = url;
  58. }
  59.  
  60. $("#btnPrevious").parent().css("display","initial");
  61. $("#btnNext").parent().css("display","initial");
  62. if($("#selectEpisode")[0].selectedIndex === 0) {
  63. $("#btnPrevious").parent().css("display","none");
  64. }
  65.  
  66. if($("#selectEpisode")[0].selectedIndex === $("#selectEpisode option").size()-1) {
  67. $("#btnNext").parent().css("display","none");
  68. }
  69. },
  70. error: function(data, textStatus, xmLHttpRequest){
  71. window.location.href = url;
  72. }
  73. });
  74. }
  75.  
  76. var link = [];
  77. var active = null;
  78. $("#selectEpisode option").each(function( index ) {
  79. link[index] = $(this).attr("value");
  80. if($("#selectEpisode").attr("value") == $(this).attr("value")){
  81. active = index;
  82. }
  83. });
  84.  
  85. if($("#btnPrevious").height() === null && $("#btnNext").height() !== null){
  86. $("#btnNext").parent().before('<a href="#!"><img id="btnPrevious" src="http://kissanime.ru/Content/images/previous.png" title="Previous episode" border="0"></a>&nbsp;&nbsp;');
  87. $("#btnPrevious").parent().css("display","none");
  88. }
  89.  
  90. if($("#btnNext").height() === null && $("#btnPrevious").height() !== null){
  91. $("#btnPrevious").parent().after('&nbsp;&nbsp;<a href="#!"><img id="btnNext" src="http://kissanime.ru/Content/images/next.png" title="Next episode" border="0"></a>');
  92. $("#btnNext").parent().css("display","none");
  93. }
  94.  
  95. $("#btnNext").parent().attr("href","#!").click(function(){
  96. if(active+1 < link.length){
  97. getvideolink(window.location.href.split('/').slice(0,5).join('/')+'/'+link[active+1]);
  98. active++;
  99. $("#selectEpisode")[0].selectedIndex = active;
  100.  
  101. }
  102. });
  103.  
  104. $("#btnPrevious").parent().attr("href","#!").click(function(){
  105. if(active > 0){
  106. getvideolink(window.location.href.split('/').slice(0,5).join('/')+'/'+link[active-1]);
  107. active--;
  108. $("#selectEpisode")[0].selectedIndex = active;
  109.  
  110. }
  111. });
  112.  
  113. $("#selectEpisode").unbind().change(function(){
  114. var before = window.location.href.split('/').slice(0,5).join('/')+'/';
  115. active = $("#selectEpisode")[0].selectedIndex;
  116. getvideolink(before+link[active]);
  117. });
  118. });
  119. })();