JWPlayer Enhancer

Auto plays JWPlayer Enhancer

2022-04-30 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         JWPlayer Enhancer
// @namespace    JWPlayerEnhancer
// @version      2
// @description  Auto plays JWPlayer Enhancer
// @author       hacker09
// @include      *
// @icon         https://www.jwplayer.com/hubfs/JW_Player_August2021/Images/favicon-152.png
// @run-at       document-end
// @grant        unsafeWindow
// ==/UserScript==

(function() {
  'use strict';
  window.onload = function() //When the page is loaded
  { //Starts the onload event listener
    var Container = unsafeWindow.jwplayer().getContainer(); //Store the jwplayer element container to a variable
    var Player = unsafeWindow.jwplayer(Container); //Store the Player element to a variable

    setTimeout(function() { //Starts the settimeout function

      function Visibility() //Create a function to check the tab visibility status
      { //Starts the function
        if (document.visibilityState === 'visible') { //If the tab is unfocused
          Player.play() //playerfullhdbeta //Plays the hd video
          Player.setFullscreen(); //Auto full screen the video
        } //Finishes the if condition
      } //Finishes the if function
      Visibility(); //Calls the function

      document.addEventListener("visibilitychange", function() { //When the tab is focused/unfocused
        //document.hasFocus = function(){return true};
        setTimeout(function() { //Starts the settimeout function
          Visibility(); //Calls the function
        }, 1000); //Finishes the settimeout function

        if (document.hidden) { //If the tab is unfocused
          Player.pause(); //Pause the video
        } //Finishes the if condition

      }, false); //Finishes the visibilitychange event listener
    }, 1500); //Finishes the settimeout function

    Player.on('complete', function() { //When the video ends
      Player.setFullscreen(false); //Leave video full screen mode
    }); //Finishes the oncomplete event listener

    Player.on('play', function() { //When the video is playing
      Player.setFullscreen(true); //Enter video full screen mode
    }); //Finishes the oncomplete event listener

    document.head.insertAdjacentHTML('beforeend', '<style>.jw-rightclick { display: none !important; }</style>'); //Hide the right click jwplayer video menu options

    document.getElementById(unsafeWindow.jwplayer().id).addEventListener('click', function(e) { //When the video is clicked
      setTimeout(function() { //Starts the settimeout function
        if (Player.getState() === 'paused') //If the video is paused
        { //Starts the if condition
          Player.setFullscreen(false); //Leave video full screen mode
        } //Finishes the if condition
      }, 500); //Finishes the settimeout function
    }); //Finishes the on click event listener

    document.getElementById(unsafeWindow.jwplayer().id).addEventListener('contextmenu', function(e) { //When the video is right clicked
      if (Player.getPosition() > 1080) //If 18 or more minutes was watched. (skip ending and next episode preview)
      { //Starts the if condition
        Player.setFullscreen(false); //Leave video full screen mode
      } //Finishes the else condition
      else //If less than 18 minutes was watched (skip the oppening)
      { //Starts the if condition
        Player.seek(Player.getPosition() + 85); //Seek 1:25 secs foward
      } //Finishes the else condition
    }); //Finishes the context menu event listener
  } //Finishes the onload event listener

})();