NoKissReload

Plays the next Episode without reloading the page

当前为 2017-04-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name NoKissReload
  3. // @version 0.15
  4. // @description Plays the next Episode 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. // @grant GM_getValue
  10. // @grant GM_setValue
  11. // @namespace https://greasyfork.org/users/92233
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. $( document ).ready(function() {
  17.  
  18. var nbShortcuts = GM_getValue( 'nbShortcuts', 0 );
  19.  
  20. function noscript(strCode){
  21. var html = $(strCode.bold());
  22. html.find('script').remove();
  23. return html.html();
  24. }
  25.  
  26. function getvideolink(url){
  27. url += "&s=beta";
  28. $.ajax({
  29. method: "GET",
  30. url: url,
  31. cache: false,
  32. success : function(data, textStatus, xmLHttpRequest){
  33. //console.log(data);
  34. history.pushState({myTag: true}, '', url);
  35. try{
  36. var newlinks = data.split('<select id="slcQualix">')[1].split('</select>')[0];
  37. var link = newlinks.split('"')[1].split('"')[0];
  38. try{
  39. $("#divFileName").html(data.split('divFileName">')[1].split('</div>')[0]);
  40. $("#divDownload").html("");
  41. var urlBefore = $('#my_video_1 video').attr('src');
  42. }catch(e){}
  43. if( $('#slcQualix').height() === null){
  44. $('#my_video_1').before('<select style="display: none;" id="slcQualix"></select>');
  45. }
  46. if( $('#slcQualix').html() === newlinks){
  47. window.location.href = url;
  48. }
  49. $('#slcQualix').html(newlinks);
  50. $("head").trigger( "click" );
  51. if($('#my_video_1').height() === null){
  52. window.location.href = url;
  53. }
  54. videojs('my_video_1').currentTime("0");
  55. $('#slcQualix').trigger("change");
  56. if(urlBefore === $('#my_video_1 video').attr('src')){
  57. SetPlayer(ovelWrap($('#slcQualix').val()));
  58. }
  59. }catch(e){
  60. console.log("error:",e);
  61. window.location.href = url;
  62. }
  63.  
  64. $("#btnPrevious").parent().css("display","initial");
  65. $("#btnNext").parent().css("display","initial");
  66. if($("#selectEpisode")[0].selectedIndex === 0) {
  67. $("#btnPrevious").parent().css("display","none");
  68. }
  69.  
  70. if($("#selectEpisode")[0].selectedIndex === $("#selectEpisode option").size()-1) {
  71. $("#btnNext").parent().css("display","none");
  72. }
  73. },
  74. error: function(data, textStatus, xmLHttpRequest){
  75. window.location.href = url;
  76. }
  77. });
  78. }
  79.  
  80. function nextE(){
  81. if(active+1 < link.length){
  82. getvideolink(window.location.href.split('/').slice(0,5).join('/')+'/'+link[active+1]);
  83. active++;
  84. $("#selectEpisode")[0].selectedIndex = active;
  85.  
  86. }
  87. }
  88.  
  89. function previosE(){
  90. if(active > 0){
  91. getvideolink(window.location.href.split('/').slice(0,5).join('/')+'/'+link[active-1]);
  92. active--;
  93. $("#selectEpisode")[0].selectedIndex = active;
  94.  
  95. }
  96. }
  97.  
  98. var link = [];
  99. var active = null;
  100. $("#selectEpisode option").each(function( index ) {
  101. link[index] = $(this).attr("value");
  102. if($("#selectEpisode").attr("value") == $(this).attr("value")){
  103. active = index;
  104. }
  105. });
  106.  
  107. if($("#btnPrevious").height() === null && $("#btnNext").height() !== null){
  108. $("#btnNext").parent().before('<a href="#!"><img id="btnPrevious" src="http://kissanime.ru/Content/images/previous.png" title="Previous episode" border="0"></a>&nbsp;&nbsp;');
  109. $("#btnPrevious").parent().css("display","none");
  110. }
  111.  
  112. if($("#btnNext").height() === null && $("#btnPrevious").height() !== null){
  113. $("#btnPrevious").parent().after('&nbsp;&nbsp;<a href="#!"><img id="btnNext" src="http://kissanime.ru/Content/images/next.png" title="Next episode" border="0"></a>');
  114. $("#btnNext").parent().css("display","none");
  115. }
  116.  
  117. $("#btnNext").parent().attr("href","#!").click(function(){
  118. nextE();
  119. });
  120.  
  121. $("#btnPrevious").parent().attr("href","#!").click(function(){
  122. previosE();
  123. });
  124.  
  125. $("#selectEpisode").unbind().change(function(){
  126. var before = window.location.href.split('/').slice(0,5).join('/')+'/';
  127. active = $("#selectEpisode")[0].selectedIndex;
  128. getvideolink(before+link[active]);
  129. });
  130.  
  131. document.onkeydown = function(evt) {
  132. evt = evt || window.event;
  133. if (evt.keyCode == 78) {
  134. if(nbShortcuts == 1){
  135. nextE();
  136. }
  137. }
  138. if (evt.keyCode == 66) {
  139. if(nbShortcuts == 1){
  140. previosE();
  141. }
  142. }
  143. };
  144.  
  145. if(nbShortcuts == 1){
  146. var check = 'checked';
  147. }else{
  148. var check = '';
  149. }
  150. $('.barContent').after('<input type="checkbox" id="nbShortcuts" '+check+' > Shortcuts ( n = next, b = back )');
  151. $('#nbShortcuts').change(function(){
  152. if($('#nbShortcuts').is(":checked")){
  153. nbShortcuts = 1;
  154. GM_setValue('nbShortcuts', 1);
  155. }else{
  156. nbShortcuts = 0;
  157. GM_setValue('nbShortcuts', 0);
  158. }
  159. });
  160.  
  161. });
  162. })();