Iwara Animation Script

Animate Iwara video thumbnail when mouse over. to make iwara easier to see.

От 27.02.2020. Виж последната версия.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey, Greasemonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Userscripts.

За да инсталирате скрипта, трябва да инсталирате разширение като Tampermonkey.

За да инсталирате този скрипт, трябва да имате инсталиран скриптов мениджър.

(Вече имам скриптов мениджър, искам да го инсталирам!)

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

(Вече имам инсталиран мениджър на стиловете, искам да го инсталирам!)

// ==UserScript==
// @name         Iwara Animation Script
// @name:ja      Iwara Animation Script
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Animate Iwara video thumbnail when mouse over. to make iwara easier to see.
// @description:ja  Iwaraの動画サムネをマウスオーバーしたときにサムネをアニメーションさせる。ちょっと見やすくする。
// @author       iwayen
// @match        *://*.iwara.tv/*
// @grant        none
// @require      http://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
// ==/UserScript==

/*
Description: //説明:
1.Makes the text on the thumbnail easier to see when loading the page. //ページ読み込み時にサムネイル上の文字を見やすく縁取りをする。
2.Zoom thumbnails on mouse over. //マウスオーバーしたときにサムネイルをズームする。
3.Then animate the thumbnail. //そのときサムネイルをアニメーションする。
About having problems: //不具合について:
1.Some videos cannot be switched because their thumbnails are 403. //一部の動画ではサムネイルが403のため切り替えできない。
2.It may take about 700ms to read an image and it may fail. //画像読み取りに700ms近くかかるため失敗することがある。
3.Since the size of the thumbnail image to be switched is different from the original size of the thumbnail, the size after execution is different from the original size. //元々のサムネのサイズと切り替えるサムネ画像のサイズが異なるので実行後サイズが元と異なる。
4.If the switching time is too early, the image cannot be downloaded. Once cached, they can be displayed faster, but are not yet supported. //切り替えの時間が早すぎると画像をダウンロードできない。一度キャッシュしていれば早くしても見えるがまだ対応していない。
*/

(function() {

    //Set here if you want to change the settings 設定を変更したい場合はここで
    var animerepeat = 1 ; //How many times do the five thumbnails repeat? Even if you increase it, the load does not increase if it is already cached. //5枚のサムネイルを何回繰り返すか。増やしてもキャッシュ済みなら負荷が増えるわけではない。
    var imagezoomscale = 1.2; //Magnification of how much to enlarge the hop-up image //ホップアップした画像をどれくれい拡大するかの倍率
    var youtubezoomscale = 2.0; //Magnification of how much you want to enlarge the hop-up image for YouTube //ホップアップしたYouTube用画像をどれくらい拡大するかの倍率
    //If you want to change the following settings, look carefully 設定を変更したい場合はここまで

    var index = 0;
    var img = '';
    var idx = 0;
    var viewimg = '';
    var nownum = 0;
    var divid = '';

    //Easy to see at border line //文字に縁取りで見やすく
    window.onload = function() {
        $(".icon-bg").css('text-shadow', '1px 1px 2px black,-1px 1px 2px black,1px -1px 2px black,-1px -1px 2px black');
    };

    $('.field-item').hover(function() {

        divid = $(this).find('.node-video,.node-image').attr('id');

        if (divid === undefined) {
            divid = $(this).attr('id');

            if (divid === undefined) {
                divid = $(this).parents('.node-video,.node-image').attr('id');

                if (divid === undefined) {
                    img = undefined
                }
            }
        }
        img = $(this).find("img").attr("src");

         if (img !== undefined) {
             $(this).css('transform', 'scale('+imagezoomscale+')');
             $(this).css('font-size', '0.3em');
             $(this).css('z-index', '100');
             $(this).css('position', 'relative');
             $(this).css('background-color', 'rgba(255,255,255,0.9)');
             $(this).css('transition', '0.3s');

             if ( img.match('_000')) {
                if ( img.match('/sidebar_preview/') === null) {
                    img = img.replace('/thumbnail/' , '/medium/');
        nownum = img.indexOf('_000');
        nownum = nownum + 4 ;
        nownum = (img[nownum]) ;
        nownum = nownum - 0 ;

                    index = img.indexOf('.jpg');
                    var defaultimage = img ;
                    index = index - 1 ;
                    img = img.substring(0, index);

                    act();
                }
             }
             else {

                 if($('#'+divid).find('.field-type-image,.field-type-file').length){

                 }else{
                     if(($('#'+divid).find('.add_ani').length)==0){
                         $(this).append('<div class="add_ani"><p class="add_comment_youtube">YouTube</p><div>');
                         $(this).find('p').css ('text-shadow', '1px 1px 2px black,-1px 1px 2px black,1px -1px 2px black,-1px -1px 2px black');
                         $(this).find('p').css ('position', 'relative');
                         $(this).find('p').css ('position', 'absolute');
                         $(this).find('p').css ('bottom', '-10px');
                         $(this).find('p').css ('left', '20px');
                         $(this).find('p').css ('color', 'white');
                         $(this).find('p').css ('font-size', '0.5em');
                     }
                     $(this).css ('transform', 'scale('+youtubezoomscale+')');

                     if(img.indexOf( '/youtube/' ) >= 0){
                         img = $(this).find("img").attr("src");
                         img = img.replace('//i.iwara.tv/sites/default/files/styles/thumbnail/public/video_embed_field_thumbnails/youtube/' , 'https://img.youtube.com/vi/');
                         img = img.replace('//i.iwara.tv/sites/default/files/styles/sidebar_preview/public/video_embed_field_thumbnails/youtube/' , 'https://img.youtube.com/vi/');
                         index = img.indexOf('.jpg');
                         img = img.substring(0, index);
                         img = img + '/hqdefault'; //youtube image size maxresdefault(1280x720) sddefault(640x480) hqdefault(480×360)

                         viewimg = img + ".jpg";
                         $('#'+divid).find("img").attr("src", viewimg);
                     }else{
                     }
                 }
             }
         }
         else {
         }

//            }, 1000);


    }, function() {

        if (img !== undefined) {

            $(this).css('transform', 'scale(1.0)');
            $(this).css('transition', '0.2s');
            $(this).css('transform', 'scale(1.0)');
            $(this).css('z-index', '0');
            $(this).css('img src', 'rgba(255,255,255,0.9)');
            $(this).css('font-size', '1.1em');
        }
    });


function act() {
    var count = 0;
    var countup = function(){
        count++
        if (nownum >= 5) { nownum = 0; }
        idx = nownum + 1;
        if(img.indexOf( 'youtube' ) == -1){
            viewimg = img + idx + ".jpg";
            $('#'+divid).find("img").attr("src", viewimg);
        }else{
        }

        nownum++;

        var id = setTimeout(countup, 800);
        if(count > ( 5 * animerepeat) - 1 ){
            clearTimeout(id);
        }
    }
    countup();
}


})();