bbs stuff

complementary to noir

目前為 2025-02-03 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         bbs stuff
// @version      2.5
// @description  complementary to noir
// @author       Jerry
// @match        *://www.1point3acres.com/*
// @match        *://newmitbbs.com/*
// @namespace    https://greasyfork.org/en/users/28298
// @homepage     https://greasyfork.org/en/scripts/456921
// @license      MIT
// ==/UserScript==

// original author: Michael Wang https://greasyfork.org/en/scripts/472251-dark-mode/code
// with help of claude ai
// https://theabbie.github.io

(function () {
    // Create a container for the buttons
    const buttonContainer = document.createElement('div');
    buttonContainer.style.position = 'fixed';  //'absolute'
    buttonContainer.style.top = '2px'; // Position at the top
    buttonContainer.style.left = '50%'; // Center horizontally
    buttonContainer.style.transform = 'translateX(-50%)'; // Adjust for exact horizontal centering
    buttonContainer.style.zIndex = '9999'; // Ensure it's on top of other elements
    buttonContainer.style.display = 'flex';
    buttonContainer.style.flexDirection = 'row'; // Arrange buttons in a row
    buttonContainer.style.gap = '10px'; // Equal spacing between buttons
    buttonContainer.style.flexWrap = 'wrap'; // Allow buttons to wrap on smaller screens
    buttonContainer.style.justifyContent = 'center'; // Center buttons horizontally
    buttonContainer.style.alignItems = 'center'; // Center buttons vertically
    buttonContainer.style.backgroundColor = 'rgba(255, 255, 255, 0)'; // Transparent background
    buttonContainer.style.padding = '5px'; // Smaller padding for the container
    buttonContainer.style.borderRadius = '5px'; // Rounded corners for the container
    buttonContainer.style.boxShadow = '0 2px 10px rgba(0, 0, 0, 0.1)'; // Add a subtle shadow

    // Array of button configurations
    const buttons = [
        { text: '👾', url: 'https://newmitbbs.com' },
        { text: '💼', url: 'https://www.1point3acres.com/bbs/forum.php?mod=guide&view=hot&mobile=2' }
    ];

    // Create and append buttons using the array
    buttons.forEach(buttonConfig => {
        const button = createButton(buttonConfig.text, buttonConfig.url);
        buttonContainer.appendChild(button);
    });

    // Append the container to the body
    document.body.appendChild(buttonContainer);



    // Create style element for dark mode
    const bbsDarkStyle = document.createElement('style');
    bbsDarkStyle.textContent = `
        html {
            filter: invert(1) hue-rotate(180deg) contrast(0.8);
        }
        /** reverse filter for media elements */
        img, video, picture, canvas, iframe, embed {
            filter: invert(1) hue-rotate(180deg);
        }
    `;

    // Initialize based on system mode
    let darkMode = window.matchMedia('(prefers-color-scheme: dark)').matches;
    if (darkMode) {
        document.head.appendChild(bbsDarkStyle);
    } else {
    document.head.removeChild(bbsDarkStyle);
    }

        // Function to create a button
    function createButton(text, url) {
        const button = document.createElement('button');
        button.innerText = text;
        button.style.padding = '0'; // Remove padding to control size explicitly
        button.style.fontSize = '18px'; // Font size
        button.style.backgroundColor = 'rgba(255, 255, 255, 0)'; // Transparent background
        button.style.color = '#ffffff'; // White text color
        button.style.border = 'none'; // Remove default border
        button.style.borderRadius = '5px'; // Rounded corners
        button.style.cursor = 'pointer'; // Pointer cursor on hover
        button.style.transition = 'background-color 0.2s'; // Smooth hover effect
        button.style.width = '40px'; // Fixed width
        button.style.height = '40px'; // Fixed height
        button.style.display = 'flex'; // Use flexbox to center content
        button.style.justifyContent = 'center'; // Center content horizontally
        button.style.alignItems = 'center'; // Center content vertically
        button.onclick = function() {
            window.location.href = url;
        };

        // Add hover effect
        button.addEventListener('mouseenter', () => {
            button.style.backgroundColor = '#0056b3'; // Darker blue on hover
        });
        button.addEventListener('mouseleave', () => {
            button.style.backgroundColor = 'rgba(255, 255, 255, 0)'; // Restore original color
        });

        return button;
    }
})();