您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Auto plays JWPlayer Enhancer
当前为
- // ==UserScript==
- // @name JWPlayer Enhancer
- // @namespace JWPlayerEnhancer
- // @version 0.1
- // @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
- })();