您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
zod.kr에서 댓글 새로고침 버튼 추가
当前为
// ==UserScript== // @name zod.kr 댓글 새로고침 버튼 // @namespace http://tampermonkey.net/ // @version 1.5 // @description zod.kr에서 댓글 새로고침 버튼 추가 // @author znjxl // @match *://zod.kr/*/* // @require https://code.jquery.com/jquery-3.6.0.min.js // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; $(document).ready(function() { const refreshButton = $('<button>댓글 새로고침</button>'); refreshButton.css({ position: 'absolute', top: '7px', right: '8px', padding: '10px', backgroundColor: '#007BFF', color: 'white', border: 'none', borderRadius: '5px', cursor: 'pointer', zIndex: '1000' }); refreshButton.on('click', () => { const params = { cpage: 50 }; // 페이지 번호를 50으로 설정 refreshComments(params).then(() => { appToast('댓글이 새로 고침되었습니다.'); }); }); function refreshComments(params) { let refresh_url = window.location.href; if (typeof params === 'object' && params.hasOwnProperty('cpage')) { refresh_url = new URL(refresh_url); refresh_url.searchParams.set('cpage', params.cpage); refresh_url = refresh_url.toString(); } return fetch(refresh_url, { credentials: "include" }) .then(response => response.text()) .then(response => { const selector = 'ul#app-board-comment-list'; const commentList = $(response).find(selector); $(selector).html(commentList.html()); const newCommentCount = commentList.children().length; const commentCountElement = $('.tw-text-sm > .tw-font-bold.tw-text-primary'); // 전체 댓글 수를 가져오는 로직 추가 const totalCommentCount = $(response).find('.tw-text-sm > .tw-font-bold.tw-text-primary').text(); // 선택자 수정 if (commentCountElement.length) { commentCountElement.text(totalCommentCount); // 전체 댓글 수로 업데이트 } if (params.hasOwnProperty('cpage')) { const currentURL = new URL(window.location.href); currentURL.searchParams.set('cpage', params.cpage); window.history.pushState({}, null, currentURL); } }); } function appToast(message) { const toast = $('<div></div>').text(message).css({ position: 'fixed', bottom: '20px', right: '20px', backgroundColor: 'rgba(0, 123, 255, 0.9)', color: 'white', padding: '10px', borderRadius: '5px', zIndex: '1000' }); $('body').append(toast); setTimeout(() => { toast.remove(); }, 3000); } const commentHeaderContainer = $('.tw-items-center.tw-flex.app-board-container.app-comment-header'); if (commentHeaderContainer.length) { commentHeaderContainer.css('position', 'relative'); commentHeaderContainer.append(refreshButton); } else { console.error('댓글 헤더가 존재하지 않습니다.'); } }); })();