[<>]+

    @@ -1,9 +1,10 @@ /* - * @title [<>] - * @description Chrome/ium well-fullscreen on LXDE or Other DE on Ubuntu + * @title [<>]+ + * @description strictly Chrome/ium well-fullscreen on LXDE or Other DE on Ubuntu * @include http://* * @include https://* - * @license CC0 Univ PD https://creativecommons.org/publicdomain/zero/1.0/ + * @contributor noromanba http://let.hatelabo.jp/noromanba/let/hJmdkteA6YED + * @license MIT License https://opensource.org/licenses/MIT * @javascript_url */ @@ -16,6 +17,59 @@ // https://caniuse.com/#feat=fullscreen // https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API -// Esc to exit -document.documentElement.webkitRequestFullScreen(); +// TBD feature detection function +(() => { + 'use strict'; + + // do not react keyboard/mouse on `html` context at few major versions e.g. + // Chromium 65.0.3325.181-0ubuntu0.16.04.1 + const context = [ + document.documentElement, + document.head, + document.body, + ].shift(); + + // chaotic naming when prefixing; Fullscreen or FullScreen c.f. + // https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API#Prefixing + + // `document.fullscreen()` is obsolete + // https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreen + // instead of `document.fullScreen()` `document.webkitIsFullScreen()` + // https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/fullscreenElement + // https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API#Prefixing + const fullscreen = + // sting feature detection for avoid Illegal invocation due to Object + 'fullscreenElement' in HTMLDocument.prototype ? + document.fullscreenElement : + 'webkitFullscreenElement' in HTMLDocument.prototype ? + document.webkitFullscreenElement : + 'webkitCurrentFullscreenElement' in HTMLDocument.prototype ? + document.webkitCurrentFullscreenElement : + new Error('not implemented yet'); + + // https://developer.mozilla.org/en-US/docs/Web/API/Document/exitFullscreen + // https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API#Prefixing + const exitFullScreen = + HTMLDocument.prototype.exitFullScreen ? + document.exitFullScreen.bind(document) : + HTMLDocument.prototype.webkitExitlFullScreen ? + document.webkitExitlFullScreen.bind(document) : + HTMLDocument.prototype.webkitCancelFullScreen ? + document.webkitCancelFullScreen.bind(document) : + new Error('not implemented yet'); + + // differences between case only; "Screen" or "screen" + // https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen + // https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API#Prefixing + const requestFullscreen = + Element.prototype.requestFullscreen ? + context.requestFullscreen.bind(context) : + Element.prototype.webkitRequestFullscreen ? + context.webkitRequestFullscreen.bind(context) : + Element.prototype.webkitRequestFullScreen ? + context.webkitRequestFullScreen.bind(context) : + new Error('not implemented yet'); + + fullscreen ? exitFullScreen() : requestFullscreen(); +})();
  • /*
     * @title [<>]+
     * @description strictly Chrome/ium well-fullscreen on LXDE or Other DE on Ubuntu
     * @include http://*
     * @include https://*
     * @contributor noromanba   http://let.hatelabo.jp/noromanba/let/hJmdkteA6YED
     * @license     MIT License https://opensource.org/licenses/MIT
     * @javascript_url
     */
    
    // ill-fullscreen c.f.
    // https://ubuntuforums.org/showthread.php?t=2244152
    // https://askubuntu.com/questions/638148/how-to-make-chrome-truly-full-screen-in-lubuntu
    // and can not fix the problem to edit ~/.config/openbox/lubuntu-rc.xml
    //
    // Fullscreen API is not standarized yet c.f.
    // https://caniuse.com/#feat=fullscreen
    // https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
    
    // TBD feature detection function
    (() => {
        'use strict';
    
        // do not react keyboard/mouse on `html` context at few major versions e.g.
        //      Chromium  65.0.3325.181-0ubuntu0.16.04.1
        const context = [
            document.documentElement,
            document.head,
            document.body,
        ].shift();
    
        // chaotic naming when prefixing; Fullscreen or FullScreen c.f.
        // https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API#Prefixing
    
        // `document.fullscreen()` is obsolete
        // https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreen
        // instead of `document.fullScreen()` `document.webkitIsFullScreen()`
        // https://developer.mozilla.org/en-US/docs/Web/API/DocumentOrShadowRoot/fullscreenElement
        // https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API#Prefixing
        const fullscreen =
            // sting feature detection for avoid Illegal invocation due to Object
            'fullscreenElement' in HTMLDocument.prototype ?
            document.fullscreenElement :
            'webkitFullscreenElement' in HTMLDocument.prototype ?
            document.webkitFullscreenElement :
            'webkitCurrentFullscreenElement' in HTMLDocument.prototype ?
            document.webkitCurrentFullscreenElement :
            new Error('not implemented yet');
    
        // https://developer.mozilla.org/en-US/docs/Web/API/Document/exitFullscreen
        // https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API#Prefixing
        const exitFullScreen =
            HTMLDocument.prototype.exitFullScreen ?
            document.exitFullScreen.bind(document) :
            HTMLDocument.prototype.webkitExitlFullScreen ?
            document.webkitExitlFullScreen.bind(document) :
            HTMLDocument.prototype.webkitCancelFullScreen ?
            document.webkitCancelFullScreen.bind(document) :
            new Error('not implemented yet');
    
        // differences between case only; "Screen" or "screen"
        // https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen
        // https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API#Prefixing
        const requestFullscreen =
            Element.prototype.requestFullscreen ?
            context.requestFullscreen.bind(context) :
            Element.prototype.webkitRequestFullscreen ?
            context.webkitRequestFullscreen.bind(context) :
            Element.prototype.webkitRequestFullScreen ?
            context.webkitRequestFullScreen.bind(context) :
            new Error('not implemented yet');
    
        fullscreen ? exitFullScreen() : requestFullscreen();
    })();
    
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2018/07/14 19:11:59 - 2018-07-14
  2. 2018/07/14 10:15:22 - 2018-07-14
  3. 2018/07/14 08:58:14 - 2018-07-14
  4. 2018/07/14 07:11:08 - 2018-07-14
  5. 2018/07/14 06:37:21 - 2018-07-14
  6. 2018/07/14 06:21:20 - 2018-07-14
  7. 2018/07/14 06:06:04 - 2018-07-14
  8. 2018/07/14 06:05:13 - 2018-07-14