您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Obtiene los trending posts de Reddit y los muestra en una página
当前为
// ==UserScript== // @license MIT // @name Obtener Trending Posts de Reddit // @namespace https://www.example.com // @version 1.0 // @description Obtiene los trending posts de Reddit y los muestra en una página // @author Tu Nombre // @match https://www.reddit.com/* // @grant none // ==/UserScript== (function() { 'use strict'; // Función para obtener los trending posts de Reddit function getTrendingPosts() { fetch('https://www.reddit.com/r/all.json') .then(response => response.json()) .then(data => { // Limpiamos el contenido anterior document.getElementById('trendingPosts').innerHTML = ''; // Recorremos los trending posts y los mostramos en la página data.data.children.forEach(post => { const postTitle = post.data.title; const postAuthor = post.data.author; const postScore = post.data.score; const postElement = document.createElement('p'); postElement.innerHTML = `<strong>${postTitle}</strong> - Autor: ${postAuthor} - Puntuación: ${postScore}`; document.getElementById('trendingPosts').appendChild(postElement); }); }) .catch(error => { console.log('Ha ocurrido un error:', error); }); } // Creamos la ventana y el botón const container = document.createElement('div'); container.className = 'container'; container.innerHTML = ` <h1>Trending Posts de Reddit</h1> <button id="getTrendingBtn">Obtener Trending Posts</button> <div id="trendingPosts"></div> `; document.body.appendChild(container); // Evento click del botón document.getElementById('getTrendingBtn').addEventListener('click', getTrendingPosts); })();