Fullscreen Shortcut

Add a shortcut to enable fullscreen mode of several streaming-media websites

目前為 2021-07-28 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Fullscreen Shortcut
// @namespace    https://greasyfork.org/users/673298
// @version      1.2.2
// @author       Fingalzzz
// @description  Add a shortcut to enable fullscreen mode of several streaming-media websites
// @homepage     https://greasyfork.org/en/scripts/408194-fullscreen-shortcut
// @supportURL   https://greasyfork.org/en/scripts/408194-fullscreen-shortcut
// @match        https://www.bilibili.com/video/*
// @match        https://www.bilibili.com/bangumi/play/*
// @match        https://www.iqiyi.com/*
// @match        https://v.qq.com/x/*
// @match        https://www.youtube.com/*
// @match        https://v.youku.com/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';
    const shortcut = '\\';

    document.addEventListener('keydown', (e) => {
        //if (e.ctrlKey && e.key === shortcut) {
        if (e.key === shortcut) {
            var selector = null;
            var btn = null;
            var link = window.location.href;
            if (link.includes("bilibili.com/bangumi")) {
                selector = ".squirtle-video-fullscreen";
            } else if (link.includes("bilibili.com/video")) {
                selector = ".bilibili-player-iconfont-fullscreen-on";
            } else if (link.includes('iqiyi.com')) {
                selector = ".iqp-btn.iqp-btn-fullscreen";
            } else if (link.includes('v.qq.com')) {
                selector = ".txp_btn.txp_btn_fullscreen";
            } else if (link.includes('youtube.com')) {
                selector = ".ytp-fullscreen-button.ytp-button";
            } else if (link.includes('v.youku.com')) {
                // Youku use different button to enable and exit fullscreen
                // so we need to check whether button we need now.
                selector = document.fullscreen? ".iconfont.icon-exit-fullscreen":".iconfont.icon-fullscreen"
            }
            btn = document.querySelector(selector);
            btn.click();
        }
    })

})();