diff --git a/content/styles/badges.css b/content/styles/badges.css index d258f7f..c047a63 100644 --- a/content/styles/badges.css +++ b/content/styles/badges.css @@ -25,11 +25,13 @@ html.rt-enabled .thing.link .flat-list li:has(> .comments) { } .rt-badge:hover { - opacity: 0.8; + filter: brightness(0.9); } -/* --- Light mode (default) --- */ +/* --- Subreddit badge: relative for gear positioning --- */ .rt-badge--subreddit { + position: relative; + padding-right: 18px; background: var(--rt-sub-bg, #fde8e0); border-color: var(--rt-sub-border, #c84a20); color: var(--rt-sub-text, #c84a20); @@ -53,3 +55,276 @@ html.rt-enabled .thing.link .flat-list li:has(> .comments) { border-color: var(--rt-com-border, #888888); color: var(--rt-com-text, #cccccc); } + +/* --- Gear icon --- */ +.rt-badge-gear { + position: absolute; + right: 3px; + top: 50%; + transform: translateY(-50%); + font-size: 10px; + line-height: 1; + opacity: 0; + pointer-events: none; + transition: opacity 0.15s; + cursor: pointer; +} + +.rt-badge--subreddit:hover .rt-badge-gear { + opacity: 0.6; + pointer-events: auto; +} + +.rt-badge-gear:hover { + opacity: 1 !important; +} + +/* --- Color popover --- */ +.rt-color-popover { + position: absolute; + z-index: 10000; + background: #fff; + border: 1px solid #ccc; + border-radius: 6px; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); + padding: 12px; + width: 260px; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; + font-size: 13px; + color: #1a1a1a; + display: none; +} + +.rt-color-popover.rt-popover-visible { + display: block; +} + +/* Popover arrow */ +.rt-color-popover::before { + content: ""; + position: absolute; + top: -6px; + left: 16px; + width: 10px; + height: 10px; + background: #fff; + border-left: 1px solid #ccc; + border-top: 1px solid #ccc; + transform: rotate(45deg); +} + +.rt-popover-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 8px; + padding-bottom: 6px; + border-bottom: 1px solid #eee; +} + +.rt-popover-title { + font-weight: 600; + font-size: 13px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + max-width: 200px; +} + +.rt-popover-close { + background: none; + border: none; + font-size: 16px; + cursor: pointer; + color: #999; + padding: 0 2px; + line-height: 1; +} + +.rt-popover-close:hover { + color: #333; +} + +.rt-popover-mode { + margin-bottom: 8px; +} + +.rt-popover-mode select { + width: 100%; + padding: 3px 6px; + border: 1px solid #ccc; + border-radius: 3px; + font-size: 12px; + font-family: inherit; +} + +.rt-popover-row { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 6px; +} + +.rt-popover-row-label { + font-size: 12px; + flex-shrink: 0; + margin-right: 8px; +} + +.rt-popover-row-inputs { + display: flex; + align-items: center; + gap: 4px; +} + +.rt-popover-row input[type="color"] { + width: 28px; + height: 20px; + border: 1px solid #ccc; + border-radius: 3px; + padding: 1px; + cursor: pointer; +} + +.rt-popover-row input[type="text"] { + width: 70px; + padding: 2px 4px; + border: 1px solid #ccc; + border-radius: 3px; + font-size: 12px; + font-family: monospace; +} + +.rt-popover-row input[type="text"].rt-input-error { + border-color: #d9534f; +} + +.rt-popover-preview { + margin: 8px 0; + padding: 6px 0; + border-top: 1px solid #eee; + border-bottom: 1px solid #eee; + text-align: center; +} + +.rt-popover-footer { + display: flex; + justify-content: space-between; + align-items: center; + margin-top: 8px; + gap: 6px; +} + +.rt-popover-footer-right { + display: flex; + gap: 6px; +} + +.rt-btn-save { + background: #4a90d9; + color: #fff; + border: 1px solid #3a7bc8; + border-radius: 3px; + padding: 4px 12px; + font-size: 12px; + cursor: pointer; +} + +.rt-btn-save:hover { + background: #3a7bc8; +} + +.rt-btn-cancel { + background: #f0f0f0; + border: 1px solid #ccc; + border-radius: 3px; + padding: 4px 10px; + font-size: 12px; + cursor: pointer; +} + +.rt-btn-cancel:hover { + background: #e0e0e0; +} + +.rt-btn-reset { + background: none; + border: 1px solid #ccc; + border-radius: 3px; + padding: 4px 10px; + font-size: 12px; + cursor: pointer; + color: #666; +} + +.rt-btn-reset:hover { + background: #f5f5f5; + color: #333; +} + +/* --- Popover dark mode --- */ +.rt-color-popover.rt-dark { + background: #2a2a2a; + border-color: #555; + color: #e0e0e0; +} + +.rt-color-popover.rt-dark::before { + background: #2a2a2a; + border-left-color: #555; + border-top-color: #555; +} + +.rt-color-popover.rt-dark .rt-popover-header { + border-bottom-color: #444; +} + +.rt-color-popover.rt-dark .rt-popover-close { + color: #888; +} + +.rt-color-popover.rt-dark .rt-popover-close:hover { + color: #ccc; +} + +.rt-color-popover.rt-dark .rt-popover-mode select { + background: #333; + border-color: #555; + color: #e0e0e0; +} + +.rt-color-popover.rt-dark .rt-popover-row input[type="color"] { + border-color: #555; +} + +.rt-color-popover.rt-dark .rt-popover-row input[type="text"] { + background: #333; + border-color: #555; + color: #e0e0e0; +} + +.rt-color-popover.rt-dark .rt-popover-preview { + border-top-color: #444; + border-bottom-color: #444; +} + +.rt-color-popover.rt-dark .rt-btn-save { + background: #4a90d9; + border-color: #3a7bc8; +} + +.rt-color-popover.rt-dark .rt-btn-cancel { + background: #444; + border-color: #555; + color: #ccc; +} + +.rt-color-popover.rt-dark .rt-btn-reset { + border-color: #555; + color: #999; +} + +.rt-color-popover.rt-dark .rt-btn-reset:hover { + background: #333; + color: #ccc; +} diff --git a/content/tweaks/badges.js b/content/tweaks/badges.js index 30082f2..c100246 100644 --- a/content/tweaks/badges.js +++ b/content/tweaks/badges.js @@ -62,6 +62,18 @@ container.setAttribute("data-rt-subreddit", subredditName); container.appendChild(badge); + const gear = document.createElement("span"); + gear.className = "rt-badge-gear"; + gear.textContent = "\u2699"; + gear.addEventListener("click", function (e) { + e.preventDefault(); + e.stopPropagation(); + if (window.RedditTweaks.colorPopover) { + window.RedditTweaks.colorPopover.open(badge, subredditName, currentSettings); + } + }); + badge.appendChild(gear); + const prevNode = subLink.previousSibling; if (prevNode && prevNode.nodeType === Node.TEXT_NODE && /\bto\s*$/.test(prevNode.textContent)) { prevNode.textContent = prevNode.textContent.replace(/\s*to\s*$/, " ");