NoKissReload

Plays the next Episode without reloading the page

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

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