Created
May 31, 2026 11:00
-
-
Save koloved/65865efc41b62d770ee01c3e55eac080 to your computer and use it in GitHub Desktop.
Копирует комментарии Reddit в ультра-компактном формате для экономии токенов
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Reddit Comments Copier (Compact) | |
| // @namespace http://tampermonkey.net/ | |
| // @version 1.3 | |
| // @description Копирует комментарии Reddit в ультра-компактном формате для экономии токенов | |
| // @match https://*.reddit.com/r/*/comments/* | |
| // @grant GM_setClipboard | |
| // @run-at document-idle | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| const btn = document.createElement('button'); | |
| btn.innerText = '📋 Copy Comments'; | |
| // Позиционирование | |
| btn.style.position = 'fixed'; | |
| btn.style.bottom = '20px'; | |
| btn.style.right = '20px'; | |
| btn.style.zIndex = '9999'; | |
| // Жесткое центрирование (исправление сдвига) | |
| btn.style.display = 'inline-flex'; | |
| btn.style.alignItems = 'center'; | |
| btn.style.justifyContent = 'center'; | |
| btn.style.height = '40px'; | |
| btn.style.padding = '0 15px'; | |
| btn.style.lineHeight = '1'; | |
| btn.style.fontSize = '14px'; | |
| btn.style.fontFamily = 'Segoe UI, Roboto, Helvetica, Arial, sans-serif'; | |
| // Оформление | |
| btn.style.backgroundColor = '#FF4500'; | |
| btn.style.color = '#fff'; | |
| btn.style.border = 'none'; | |
| btn.style.borderRadius = '20px'; | |
| btn.style.cursor = 'pointer'; | |
| btn.style.fontWeight = 'bold'; | |
| btn.style.boxShadow = '0 4px 6px rgba(0,0,0,0.1)'; | |
| document.body.appendChild(btn); | |
| btn.addEventListener('click', () => { | |
| const commentElements = document.querySelectorAll('div[slot="comment"], div[data-testid="comment"]'); | |
| let compiledText = ''; | |
| let count = 1; | |
| commentElements.forEach((el) => { | |
| let text = el.innerText || el.textContent; | |
| text = text.trim(); | |
| if (!text) { | |
| const img = el.querySelector('img'); | |
| if (img && img.src) { | |
| text = `[Image:${img.src}]`; | |
| } | |
| } | |
| if (text) { | |
| compiledText += `${count}-${text}\n`; | |
| count++; | |
| } | |
| }); | |
| if (compiledText) { | |
| GM_setClipboard(compiledText.trim()); | |
| btn.innerText = `✅ Copied ${count - 1}!`; | |
| setTimeout(() => { btn.innerText = '📋 Copy Comments'; }, 2000); | |
| } else { | |
| btn.innerText = '❌ No comments found'; | |
| setTimeout(() => { btn.innerText = '📋 Copy Comments'; }, 2000); | |
| } | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment