F11全屏失败修复工具+全屏自定义

make F11 available

// ==UserScript==
// @name         F11全屏失败修复工具+全屏自定义
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  make F11 available
// @author       lolucas
// @match        *://*/*
// @license MIT
// @icon         https://cdn0.iconfinder.com/data/icons/keyboard-6/24/Function-128.png
// @grant        none
// ==/UserScript==

(function() {
    /**********************************************
    在这自定义!(keynum)
    全屏的按键码:
    ***********************************************/
    var keynum = 122;

    function toggleFullScreen() {
        var element = document.documentElement; // 获取整个文档的元素

        // 判断当前是否已经是全屏状态
        if (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement) {
            // 如果是全屏状态,就退出全屏
            if (document.exitFullscreen) {
                document.exitFullscreen();
            } else if (document.webkitExitFullscreen) {
                document.webkitExitFullscreen();
            } else if (document.mozCancelFullScreen) {
                document.mozCancelFullScreen();
            } else if (document.msExitFullscreen) {
                document.msExitFullscreen();
            }
        } else {
            // 如果不是全屏状态,就进入全屏
            if (element.requestFullscreen) {
                element.requestFullscreen();
            } else if (element.webkitRequestFullscreen) {
                element.webkitRequestFullscreen();
            } else if (element.mozRequestFullScreen) {
                element.mozRequestFullScreen();
            } else if (element.msRequestFullscreen) {
                element.msRequestFullscreen();
            }
        }
    }
    document.onkeydown = function(event){
        if(event.keyCode==keynum){
            toggleFullScreen();
        }
    }
})();