您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
gether all comments from a reddit post
当前为
// ==UserScript== // @icon https://www.reddit.com/favicon.ico // @name Reddit comment collector // @author grefork // @description gether all comments from a reddit post // @match *://www.reddit.com/r/*/comments/* // @version 1.4.1 // @namespace grefork // @require http://code.jquery.com/jquery-3.4.1.min.js // @grant GM_addStyle // ==/UserScript== { const commentClass = "._1qeIAgB0cPwnLhDF9XSiJM"; const insertClass = "._1r4smTyOEZFO91uFIdWW6T"; const init = async () => { try { if($(insertClass).get().length ==0) throw new Error('Wait for loading') function getComments() { if ($("#commentList").get().length > 0) return const textList = $(commentClass) var commentList = []; for (var i=0;i<textList.length;i++) { if(textList[i].textContent.includes("http")) continue; var splitted = textList[i].textContent.split(/[.?!。]+/); console.log(splitted) for (var j=0; j<splitted.length; j++){ if(splitted[j].length > 5 && !commentList.includes(splitted[j])) commentList.push(splitted[j].trim()); } } var textarea = document.createElement("textarea"); textarea.id = "commentList"; textarea.value = commentList.join("\n"); textarea.style.cssText = "width:100%;height:200px" $(insertClass).get()[0].appendChild(textarea); } var button = document.createElement("button"); button.innerText = "LOAD COMMENT"; button.style.cssText = "background-color:#327bb3;padding:5px" button.onclick = getComments $(insertClass).get()[0].appendChild(button); } catch (_) { setTimeout(init, 1000); } }; init(); }