Better Fullscreen AIFap

fullscreen for aifap

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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);
}