Cam4.com toggle fullscreen

Toggle your porno fullscreen with alt+enter.

目前為 2018-11-10 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name Cam4.com toggle fullscreen
// @namespace CAM4
// @description Toggle your porno fullscreen with alt+enter.
// @version 2
// @include https://www.cam4.com/*
// @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;
    }
}