Fullscreen Toggle Button

Add a fullscreen button to bottom-left corner of any webpage

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Fullscreen Toggle Button
// @namespace    https://shuhaibnc.github.io
// @version      1.0
// @description  Add a fullscreen button to bottom-left corner of any webpage
// @author       ShuhaibNC
// @match        *://*/*
// @grant        none
// @license MIT
// @run-at       document-end
// ==/UserScript==

(function () {
    'use strict';

    const btn = document.createElement('button');
    btn.innerText = '⛶';
    btn.title = 'Toggle Fullscreen';
    Object.assign(btn.style, {
        position: 'fixed',
        bottom: '10px',
        left: '10px',
        zIndex: 99999,
        background: '#111',
        color: '#fff',
        border: '1px solid #444',
        padding: '10px 14px',
        borderRadius: '8px',
        fontSize: '16px',
        cursor: 'pointer',
        opacity: '0.7',
        transition: 'opacity 0.3s',
    });

    btn.addEventListener('mouseenter', () => btn.style.opacity = '1');
    btn.addEventListener('mouseleave', () => btn.style.opacity = '0.7');

    btn.addEventListener('click', () => {
        const doc = document.documentElement;
        if (!document.fullscreenElement) {
            doc.requestFullscreen().catch(err => alert(`Failed: ${err.message}`));
        } else {
            document.exitFullscreen();
        }
    });

    document.body.appendChild(btn);
})();