Agrega un botón en Reddit para abrir Reddit-stream
当前为
// ==UserScript==
// @name Reddit Stream Button
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Agrega un botón en Reddit para abrir Reddit-stream
// @author Daniel
// @match *://www.reddit.com/r/*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// Función para agregar el botón
function addStreamButton() {
// Evita agregar múltiples botones
if (document.querySelector("#reddit-stream-button")) return;
// Crea el botón y lo personaliza
const button = document.createElement("button");
button.id = "reddit-stream-button";
button.textContent = "Ver en Reddit Stream";
button.style.margin = "10px";
button.style.padding = "8px 12px";
button.style.backgroundColor = "#FF5700";
button.style.color = "white";
button.style.border = "none";
button.style.borderRadius = "4px";
button.style.cursor = "pointer";
// Obtén el nombre del subreddit desde la URL
const subredditMatch = window.location.pathname.match(/\/r\/([^/]+)/);
if (subredditMatch) {
const subreddit = subredditMatch[1];
button.onclick = () => {
window.open(`https://reddit-stream.com/r/${subreddit}`, "_blank");
};
// Inserta el botón en la cabecera del subreddit
const header = document.querySelector("header");
if (header) {
header.appendChild(button);
}
}
}
// Espera a que el DOM se cargue completamente
window.addEventListener("load", addStreamButton);
// Observa cambios en la página para agregar el botón si se carga dinámicamente
const observer = new MutationObserver(addStreamButton);
observer.observe(document.body, { childList: true, subtree: true });
})();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址