Reddit Stream Button

Agrega un botón en Reddit para abrir Reddit-stream en el credit-bar del post con la URL correcta de Reddit Stream y texto centrado en el botón

  1. // ==UserScript==
  2. // @name Reddit Stream Button
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.3
  5. // @description Agrega un botón en Reddit para abrir Reddit-stream en el credit-bar del post con la URL correcta de Reddit Stream y texto centrado en el botón
  6. // @author Daniel
  7. // @match *://www.reddit.com/r/*/comments/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function addStreamButton() {
  16. // Evita agregar múltiples botones
  17. if (document.querySelector("#reddit-stream-button")) return;
  18.  
  19. // Crea el botón y lo personaliza
  20. const button = document.createElement("button");
  21. button.id = "reddit-stream-button";
  22. button.textContent = "Reddit-Stream";
  23. button.style.marginLeft = "10px";
  24. button.style.padding = "4px 8px";
  25. button.style.backgroundColor = "#FF5700";
  26. button.style.color = "white";
  27. button.style.border = "none";
  28. button.style.borderRadius = "4px";
  29. button.style.cursor = "pointer";
  30. button.style.fontSize = "12px";
  31.  
  32. // Estilos para centrar el texto
  33. button.style.display = "flex";
  34. button.style.justifyContent = "center";
  35. button.style.alignItems = "center";
  36. button.style.textAlign = "center";
  37.  
  38. // Extrae los elementos 'comments' y el ID del post de la URL
  39. const pathMatch = window.location.pathname.match(/\/comments\/([a-z0-9]+)/);
  40. if (pathMatch) {
  41. const postId = pathMatch[1];
  42. button.onclick = () => {
  43. window.open(`https://reddit-stream.com/comments/${postId}/`, "_blank");
  44. };
  45.  
  46. // Encuentra el contenedor de credit-bar para insertar el botón
  47. const creditBar = document.querySelector('div[slot="credit-bar"]');
  48. if (creditBar) {
  49. creditBar.appendChild(button);
  50. }
  51. }
  52. }
  53.  
  54. // Observa cambios en la página para agregar el botón si se carga dinámicamente
  55. const observer = new MutationObserver(addStreamButton);
  56. observer.observe(document.body, { childList: true, subtree: true });
  57.  
  58. // Llama a la función para intentar agregar el botón en la carga inicial
  59. addStreamButton();
  60. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址