X Bookmarks Quick Access

Show floating bookmark button on Twitter/X pages only

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         X Bookmarks Quick Access
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Show floating bookmark button on Twitter/X pages only
// @author       biganthonymo
// @match        *://x.com/*
// @match        *://www.x.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
    'use strict';

    // Avoid duplicates
    if (document.getElementById('x-bookmark-btn')) return;

    const btn = document.createElement('div');
    btn.id = 'x-bookmark-btn';
    btn.innerHTML = `
        <svg xmlns="http://www.w3.org/2000/svg" fill="#fff" viewBox="0 0 24 24" width="24px" height="24px">
            <path d="M17 3H7a2 2 0 00-2 2v16l7-3.18L17 21V5a2 2 0 00-2-2z"/>
        </svg>
    `;

    Object.assign(btn.style, {
        position: 'fixed',
        top: '20px',
        left: '20px',
        width: '50px',
        height: '50px',
        backgroundColor: '#1DA1F2',
        borderRadius: '50%',
        boxShadow: '0 2px 6px rgba(0,0,0,0.3)',
        display: 'flex',
        alignItems: 'center',
        justifyContent: 'center',
        cursor: 'pointer',
        zIndex: '99999',
        transition: 'transform 0.2s ease',
    });

    btn.addEventListener('mouseenter', () => {
        btn.style.transform = 'scale(1.1)';
    });

    btn.addEventListener('mouseleave', () => {
        btn.style.transform = 'scale(1)';
    });

    btn.title = 'Go to Bookmarks';
    btn.onclick = () => {
        window.location.href = 'https://x.com/i/bookmarks';
    };

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