Hovering Back Button (Bottom Right)

Adds a hovering back button to the bottom right corner of the webpage

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Hovering Back Button (Bottom Right)
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Adds a hovering back button to the bottom right corner of the webpage
// @author       Your Name
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Create the button element
    let backButton = document.createElement('button');
    backButton.id = 'backButton';
    backButton.innerText = 'Back';
    
    // Apply styles to the button
    backButton.style.position = 'fixed';
    backButton.style.bottom = '20px'; // Position from the bottom of the page
    backButton.style.right = '20px'; // Position from the right of the page
    backButton.style.padding = '10px 20px';
    backButton.style.backgroundColor = 'rgba(128, 128, 128, 0.5)'; // Gray background with 50% transparency
    backButton.style.color = 'white';
    backButton.style.border = 'none';
    backButton.style.borderRadius = '5px';
    backButton.style.cursor = 'pointer';
    backButton.style.fontSize = '16px';
    backButton.style.transition = 'background-color 0.3s ease';

    // Add hover effect
    backButton.addEventListener('mouseenter', function() {
        backButton.style.backgroundColor = 'rgba(80, 80, 80, 0.7)'; // Slightly darker gray with 70% transparency on hover
    });

    backButton.addEventListener('mouseleave', function() {
        backButton.style.backgroundColor = 'rgba(128, 128, 128, 0.5)'; // Original gray with 50% transparency
    });

    // Add click event to go back
    backButton.addEventListener('click', function() {
        window.history.back();
    });

    // Append the button to the body
    document.body.appendChild(backButton);

})();