NoKissReload

Plays the next video without reloading the page

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

  1. // ==UserScript==
  2. // @name NoKissReload
  3. // @version 0.13
  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. }catch(e){}
  38. if( $('#slcQualix').html() === newlinks){
  39. window.location.href = url;
  40. }
  41. $('#slcQualix').html(newlinks);
  42. $("head").trigger( "click" );
  43. if($('#my_video_1').height() === null){
  44. window.location.href = url;
  45. }
  46. videojs('my_video_1').currentTime("0");
  47. $('#slcQualix').trigger("change");
  48. }catch(e){
  49. console.log("error:",e);
  50. window.location.href = url;
  51. }
  52.  
  53. $("#btnPrevious").parent().css("display","initial");
  54. $("#btnNext").parent().css("display","initial");
  55. if($("#selectEpisode")[0].selectedIndex === 0) {
  56. $("#btnPrevious").parent().css("display","none");
  57. }
  58.  
  59. if($("#selectEpisode")[0].selectedIndex === $("#selectEpisode option").size()-1) {
  60. $("#btnNext").parent().css("display","none");
  61. }
  62. },
  63. error: function(data, textStatus, xmLHttpRequest){
  64. window.location.href = url;
  65. }
  66. });
  67. }
  68.  
  69. var link = [];
  70. var active = null;
  71. $("#selectEpisode option").each(function( index ) {
  72. link[index] = $(this).attr("value");
  73. if($("#selectEpisode").attr("value") == $(this).attr("value")){
  74. active = index;
  75. }
  76. });
  77.  
  78. if($("#btnPrevious").height() === null && $("#btnNext").height() !== null){
  79. $("#btnNext").parent().before('<a href="#!"><img id="btnPrevious" src="http://kissanime.ru/Content/images/previous.png" title="Previous episode" border="0"></a>&nbsp;&nbsp;');
  80. $("#btnPrevious").parent().css("display","none");
  81. }
  82.  
  83. if($("#btnNext").height() === null && $("#btnPrevious").height() !== null){
  84. $("#btnPrevious").parent().after('&nbsp;&nbsp;<a href="#!"><img id="btnNext" src="http://kissanime.ru/Content/images/next.png" title="Next episode" border="0"></a>');
  85. $("#btnNext").parent().css("display","none");
  86. }
  87.  
  88. $("#btnNext").parent().attr("href","#!").click(function(){
  89. if(active+1 < link.length){
  90. getvideolink(window.location.href.split('/').slice(0,5).join('/')+'/'+link[active+1]);
  91. active++;
  92. $("#selectEpisode")[0].selectedIndex = active;
  93.  
  94. }
  95. });
  96.  
  97. $("#btnPrevious").parent().attr("href","#!").click(function(){
  98. if(active > 0){
  99. getvideolink(window.location.href.split('/').slice(0,5).join('/')+'/'+link[active-1]);
  100. active--;
  101. $("#selectEpisode")[0].selectedIndex = active;
  102.  
  103. }
  104. });
  105.  
  106. $("#selectEpisode").unbind().change(function(){
  107. var before = window.location.href.split('/').slice(0,5).join('/')+'/';
  108. active = $("#selectEpisode")[0].selectedIndex;
  109. getvideolink(before+link[active]);
  110. });
  111. });
  112. })();