Better Fullscreen AIFap

fullscreen for aifap

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Better Fullscreen AIFap
// @include     *aifap.net/view/*
// @run-at      document-start
// @grant       GM_addStyle
// @locale en
// @description fullscreen for aifap
// @version 0.0.1.20190111070049
// @namespace https://greasyfork.org/users/31574
// ==/UserScript==
/*- The @grant directive is needed to work around a design change
    introduced in GM 1.0.   It restores the sandbox.
*/

async function GM_main () {
  
    document.showing = false;
  
    function sleep(ms) {
      return new Promise(resolve => setTimeout(resolve, ms));
    }
    
    await sleep(2000); 
  
    var info = document.getElementsByClassName('AIF-PostInformation')[0];
    var topBar = document.getElementsByClassName('AIF-MainHeader')[0];
    var postViewer = document.getElementsByClassName('AIF-PostViewer')[0];
    var image = document.getElementsByClassName('AIF-PostViewerImage')[0];
    var content = document.getElementsByClassName('AIF-PostViewer__Content')[0];
    
    var FullScreenBtn = document.createElement("BUTTON");
    FullScreenBtn.id = "fullscreen";
    FullScreenBtn.textContent = "Fullscreen";
    FullScreenBtn.onclick = function() {
    // if already full screen; exit
    // else go fullscreen
    if (
      document.fullscreenElement ||
      document.webkitFullscreenElement ||
      document.mozFullScreenElement ||
      document.msFullscreenElement
    ) {
      if (document.exitFullscreen) {
        document.exitFullscreen();
        var cssStyle = document.createElement('style');
        cssStyle.type = 'text/css';
        var rules = document.createTextNode(".AIF-PostViewer__Content{height: 100%}");
        cssStyle.appendChild(rules);
        document.getElementsByTagName("head")[0].appendChild(cssStyle);
      } 
    } else {
      if (postViewer.requestFullscreen) {
        postViewer.requestFullscreen();
         
        var cssStyle = document.createElement('style');
        cssStyle.type = 'text/css';
        var rules = document.createTextNode(".AIF-PostViewer__Content{height: 100% !important}");
        cssStyle.appendChild(rules);
        document.getElementsByTagName("head")[0].appendChild(cssStyle);
      } 
    }
}
  
    document.getElementsByClassName('AIF-MainHeader__Nav')[0].appendChild(FullScreenBtn);
    
    
}

addJS_Node (null, null, GM_main);

function addJS_Node (text, s_URL, funcToRun, runOnLoad) {
    var D                                   = document;
    var scriptNode                          = D.createElement ('script');
    if (runOnLoad) {
        scriptNode.addEventListener ("load", runOnLoad, false);
    }
    scriptNode.type                         = "text/javascript";
    if (text)       scriptNode.textContent  = text;
    if (s_URL)      scriptNode.src          = s_URL;
    if (funcToRun)  scriptNode.textContent  = '(' + funcToRun.toString() + ')()';

    var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement;
    targ.appendChild (scriptNode);
}