NoKissReload

Plays the next video without reloading the page

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

  1. // ==UserScript==
  2. // @name NoKissReload
  3. // @version 0.1
  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. function getvideolink(url){
  16. $.ajax({
  17. method: "GET",
  18. url: url,
  19. cache: false,
  20. success : function(data, textStatus, xmLHttpRequest){
  21. //console.log(data);
  22. history.pushState({myTag: true}, '', url);
  23. var newlinks = data.split('<select id="selectQuality">')[1].split('</select>')[0];
  24. var link = newlinks.split('"')[1].split('"')[0];
  25. $("#divDownload").html(data.split('divDownload">')[1].split('</div>')[0]);
  26. $("#divFileName").html(data.split('divFileName">')[1].split('</div>')[0]);
  27. $('#selectQuality').html(newlinks);
  28. $("head").trigger( "click" );
  29. videojs('my_video_1').currentTime("0");
  30. $('#selectQuality').trigger("change");
  31.  
  32. $("#btnPrevious").parent().css("display","initial");
  33. $("#btnNext").parent().css("display","initial");
  34. if($("#selectEpisode")[0].selectedIndex === 0) {
  35. $("#btnPrevious").parent().css("display","none");
  36. }
  37.  
  38. if($("#selectEpisode")[0].selectedIndex === $("#selectEpisode option").size()-1) {
  39. $("#btnNext").parent().css("display","none");
  40. }
  41. },
  42. error: function(data, textStatus, xmLHttpRequest){
  43. window.location.href = url;
  44. }
  45. });
  46. }
  47.  
  48. var link = [];
  49. var active = null;
  50. $("#selectEpisode option").each(function( index ) {
  51. link[index] = $(this).attr("value");
  52. if($("#selectEpisode").attr("value") == $(this).attr("value")){
  53. active = index;
  54. }
  55. });
  56.  
  57. if($("#btnPrevious").height() === null && $("#btnNext").height() !== null){
  58. $("#btnNext").parent().before('<a href="#!"><img id="btnPrevious" src="http://kissanime.ru/Content/images/previous.png" title="Previous episode" border="0"></a>&nbsp;&nbsp;');
  59. $("#btnPrevious").parent().css("display","none");
  60. }
  61.  
  62. if($("#btnNext").height() === null && $("#btnPrevious").height() !== null){
  63. $("#btnPrevious").parent().after('&nbsp;&nbsp;<a href="#!"><img id="btnNext" src="http://kissanime.ru/Content/images/next.png" title="Next episode" border="0"></a>');
  64. $("#btnNext").parent().css("display","none");
  65. }
  66.  
  67. $("#btnNext").parent().attr("href","#!").click(function(){
  68. if(active+1 < link.length){
  69. getvideolink(window.location.href.split('/').slice(0,5).join('/')+'/'+link[active+1]);
  70. active++;
  71. $("#selectEpisode")[0].selectedIndex = active;
  72.  
  73. }
  74. });
  75.  
  76. $("#btnPrevious").parent().attr("href","#!").click(function(){
  77. if(active > 0){
  78. getvideolink(window.location.href.split('/').slice(0,5).join('/')+'/'+link[active-1]);
  79. active--;
  80. $("#selectEpisode")[0].selectedIndex = active;
  81.  
  82. }
  83. });
  84.  
  85. $("#selectEpisode").unbind().change(function(){
  86. var before = window.location.href.split('/').slice(0,5).join('/')+'/';
  87. active = $("#selectEpisode")[0].selectedIndex;
  88. getvideolink(before+link[active]);
  89. });
  90. });
  91. })();