NoKissReload

Plays the next video without reloading the page

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

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