X Bookmarks Quick Access

Show floating bookmark button on Twitter/X pages only

  1. // ==UserScript==
  2. // @name X Bookmarks Quick Access
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Show floating bookmark button on Twitter/X pages only
  6. // @author biganthonymo
  7. // @match *://x.com/*
  8. // @match *://www.x.com/*
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15.  
  16. // Avoid duplicates
  17. if (document.getElementById('x-bookmark-btn')) return;
  18.  
  19. const btn = document.createElement('div');
  20. btn.id = 'x-bookmark-btn';
  21. btn.innerHTML = `
  22. <svg xmlns="http://www.w3.org/2000/svg" fill="#fff" viewBox="0 0 24 24" width="24px" height="24px">
  23. <path d="M17 3H7a2 2 0 00-2 2v16l7-3.18L17 21V5a2 2 0 00-2-2z"/>
  24. </svg>
  25. `;
  26.  
  27. Object.assign(btn.style, {
  28. position: 'fixed',
  29. top: '20px',
  30. left: '20px',
  31. width: '50px',
  32. height: '50px',
  33. backgroundColor: '#1DA1F2',
  34. borderRadius: '50%',
  35. boxShadow: '0 2px 6px rgba(0,0,0,0.3)',
  36. display: 'flex',
  37. alignItems: 'center',
  38. justifyContent: 'center',
  39. cursor: 'pointer',
  40. zIndex: '99999',
  41. transition: 'transform 0.2s ease',
  42. });
  43.  
  44. btn.addEventListener('mouseenter', () => {
  45. btn.style.transform = 'scale(1.1)';
  46. });
  47.  
  48. btn.addEventListener('mouseleave', () => {
  49. btn.style.transform = 'scale(1)';
  50. });
  51.  
  52. btn.title = 'Go to Bookmarks';
  53. btn.onclick = () => {
  54. window.location.href = 'https://x.com/i/bookmarks';
  55. };
  56.  
  57. document.body.appendChild(btn);
  58. })();