Greasy Fork

Kissanime Video at the Top

Move video to the top of the page. Keep video visible when scrolling down to see comments. Auto show comments.

目前为 2018-03-08 提交的版本。查看 最新版本

// ==UserScript==
// @name         Kissanime Video at the Top
// @namespace    superschwul
// @version      1.0
// @description  Move video to the top of the page. Keep video visible when scrolling down to see comments. Auto show comments.
// @author       Superschwul
// @match        http://kissanime.ru/Anime/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var body = document.getElementsByTagName('body')[0];
    var navContainer = document.getElementsByClassName('barContent')[0];
    if(navContainer == null) {
        throw '';
    }
    var nav = navContainer.children[0].children[0];
    var videoContainer = document.createElement('div');
    var video = document.getElementById('centerDivVideo');

    nav.id = 'episodeNav';
    videoContainer.id = 'videoContainer';
    body.insertBefore(videoContainer, body.firstChild);
    videoContainer.appendChild(video);
    body.insertBefore(nav, body.firstChild);

    var style = document.createElement('style');
    style.innerHTML = `
        body {
            width: 100vw;
            overflow-x: hidden;
        }
        #episodeNav {
            height: 30px;
        }
        #videoContainer {
            height: 552px;
        }
        #centerDivVideo {
            display: block !important;
            margin: 0 auto 20px auto;
            z-index: 90;
        }
        #divComments {
            width: 46vw !important;
            margin: 0 0 0 2vw !important;
        }
        #divComments > div:first-child {
            width: 94% !important;
        }

        body.fixed #centerDivVideo {
            position: fixed !important;
            right: 2vw;
            width: 46vw !important;
        }
        body.fixed #divContentVideo {
            width: 100% !important;
            height: 80vh !important;
        }
        body.fixed #divContentVideo iframe {
            width: 100% !important;
            height: 100% !important;
        }
    `;
    document.getElementsByTagName('head')[0].appendChild(style);

    var runOnScroll = function(ev) {
        document.body.className = '';
        if(window.pageYOffset > 400) {
            document.body.className = 'fixed';
        }
    };
    window.addEventListener('scroll', runOnScroll);

    document.getElementById('btnShowComments').click();

})();