Cam4 toggle fullscreen

Toggle your porno fullscreen with alt+enter.

ของเมื่อวันที่ 10-11-2018 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name Cam4 toggle fullscreen
// @description Toggle your porno fullscreen with alt+enter.
// @version 1
// @namespace Violentmonkey Scripts
// @match https://www.cam4.com/*
// @grant none
// ==/UserScript==

window.onload = initialize;

var _isFullScreen = false;
var _htmlTag, _cam4HLSPlayer, _originalCam4HLSPlayerStyle = null;

function initialize() {
  try {
    _htmlTag = document.getElementsByTagName('html')[0];
    _cam4HLSPlayer = document.getElementById('Cam4HLSPlayer');
    _originalCam4HLSPlayerStyle = _cam4HLSPlayer.style;
    
    HLS.disconnect = null;
    document.addEventListener('keydown', catchKeyDown, false);
  } catch (exception) {
    console.warn('initialize.exception', exception);
  }
}

function catchKeyDown(e) {
   if (e.keyCode == 13 && e.altKey) {
     toggleFullScreen();
   }
}

function toggleFullScreen() {
    _isFullScreen = !_isFullScreen
    _htmlTag.style['overflow'] = _isFullScreen ? 'hidden' : 'auto';
    if (_isFullScreen) {
      _cam4HLSPlayer.style['position'] = 'fixed';
      _cam4HLSPlayer.style['top'] = 0;
      _cam4HLSPlayer.style['left'] = 0;
      _cam4HLSPlayer.style['height'] = '100vh';
      _cam4HLSPlayer.style['width'] = '100vw';
      _cam4HLSPlayer.style['z-index'] = 99999;
    } else {
      _cam4HLSPlayer.style = _originalCam4HLSPlayerStyle;
    }
}