您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
zod.kr에서 댓글 새로고침 버튼 추가
当前为
// ==UserScript== // @name zod.kr 댓글 새로고침 버튼 // @namespace http://tampermonkey.net/ // @version 1.6 // @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', () => { // 댓글 새로고침 함수 호출 refreshComments({ cpage: 50 }).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 totalCommentCount = $(response).find('.tw-text-sm > .tw-font-bold.tw-text-primary').text(); const commentCountElement = $('.tw-text-sm > .tw-font-bold.tw-text-primary'); 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); } // 특정 버튼 클릭 시 댓글 새로고침 $('.tw-pl-2.tw-flex-1 > .tw-items-start.tw-flex > .primary.app-button-xs.app-button-rounded.app-button').on('click', () => { // 1초 후에 댓글 새로고침 setTimeout(() => { refreshComments({ cpage: 50 }).then(() => { appToast('댓글이 새로 고침되었습니다.'); }); }, 1000); }); // 댓글 헤더에 버튼 추가 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('댓글 헤더가 존재하지 않습니다.'); } }); })();