NoKissReload

Plays the next video without reloading the page

目前為 2017-03-15 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         NoKissReload
// @version      0.11
// @description  Plays the next video without reloading the page
// @author       [email protected]
// @license      Creative Commons; http://creativecommons.org/licenses/by/4.0/
// @match        http://kissanime.ru/Anime/*/*
// @grant        GM_xmlhttpRequest
// @namespace    https://greasyfork.org/users/92233
// ==/UserScript==

(function() {
    'use strict';
    $( document ).ready(function() {

        function noscript(strCode){
           var html = $(strCode.bold()); 
           html.find('script').remove();
         return html.html();
        }

        function getvideolink(url){
            url += "&s=beta";
            $.ajax({
                method: "GET",
                url: url,
                cache: false,
                success : function(data, textStatus, xmLHttpRequest){
                    //console.log(data);
                    history.pushState({myTag: true}, '', url);
                    try{
                        var newlinks = data.split('<select id="slcQualix">')[1].split('</select>')[0];
                        var link = newlinks.split('"')[1].split('"')[0];
                        try{
                            $("#divFileName").html(data.split('divFileName">')[1].split('</div>')[0]);
                            $("#divDownload").html("");
                        }catch(e){}
                        $('#slcQualix').html(newlinks);
                        $("head").trigger( "click" );
                        videojs('my_video_1').currentTime("0");
                        $('#slcQualix').trigger("change");
                    }catch(e){
                        console.log("error:",e);
                        window.location.href = url;
                    }

                    $("#btnPrevious").parent().css("display","initial");
                    $("#btnNext").parent().css("display","initial");
                    if($("#selectEpisode")[0].selectedIndex === 0) {
                        $("#btnPrevious").parent().css("display","none");
                    }

                    if($("#selectEpisode")[0].selectedIndex === $("#selectEpisode option").size()-1) {
                        $("#btnNext").parent().css("display","none");
                    }
                },
                error: function(data, textStatus, xmLHttpRequest){
                    window.location.href = url;
                }
            });
        }

        var link = [];
        var active = null;
        $("#selectEpisode option").each(function( index ) {
            link[index] = $(this).attr("value");
            if($("#selectEpisode").attr("value") == $(this).attr("value")){
                active = index;
            }
        });

        if($("#btnPrevious").height() === null && $("#btnNext").height() !== null){
            $("#btnNext").parent().before('<a href="#!"><img id="btnPrevious" src="http://kissanime.ru/Content/images/previous.png" title="Previous episode" border="0"></a>&nbsp;&nbsp;');
            $("#btnPrevious").parent().css("display","none");
        }

        if($("#btnNext").height() === null && $("#btnPrevious").height() !== null){
            $("#btnPrevious").parent().after('&nbsp;&nbsp;<a href="#!"><img id="btnNext" src="http://kissanime.ru/Content/images/next.png" title="Next episode" border="0"></a>');
            $("#btnNext").parent().css("display","none");
        }

        $("#btnNext").parent().attr("href","#!").click(function(){
            if(active+1 < link.length){
                getvideolink(window.location.href.split('/').slice(0,5).join('/')+'/'+link[active+1]);
                active++;
                $("#selectEpisode")[0].selectedIndex = active;

            }
        });

        $("#btnPrevious").parent().attr("href","#!").click(function(){
            if(active > 0){
                getvideolink(window.location.href.split('/').slice(0,5).join('/')+'/'+link[active-1]);
                active--;
                $("#selectEpisode")[0].selectedIndex = active;

            }
        });

        $("#selectEpisode").unbind().change(function(){
            var before = window.location.href.split('/').slice(0,5).join('/')+'/';
            active = $("#selectEpisode")[0].selectedIndex;
            getvideolink(before+link[active]);
        });
    });
})();