Warning: fopen(/www/sites/update.greasyfork.icu/index/store/temp/d731b4ffefc2372c02c17dae76dcb125.js): failed to open stream: No space left on device in /www/sites/update.greasyfork.icu/index/scriptControl.php on line 65
// ==UserScript==
// @name 네이버 카페 - 댓글 클리너
// @name:ko 네이버 카페 - 댓글 클리너
// @description 네이버 카페 댓글 이모티콘 숨기기, 내용 없는 댓글 숨기기
// @description:ko 네이버 카페 댓글 이모티콘 숨기기, 내용 없는 댓글 숨기기
// @namespace http://tampermonkey.net/
// @version 20240316
// @author You
// @match https://cafe.naver.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=naver.com
// @grant GM_addStyle
// @run-at document-end
// @license MIT
// @downloadURL https://update.greasyfork.icu/scripts/489811/%EB%84%A4%EC%9D%B4%EB%B2%84%20%EC%B9%B4%ED%8E%98%20-%20%EB%8C%93%EA%B8%80%20%ED%81%B4%EB%A6%AC%EB%84%88.user.js
// @updateURL https://update.greasyfork.icu/scripts/489811/%EB%84%A4%EC%9D%B4%EB%B2%84%20%EC%B9%B4%ED%8E%98%20-%20%EB%8C%93%EA%B8%80%20%ED%81%B4%EB%A6%AC%EB%84%88.meta.js
// ==/UserScript==
(function() {
'use strict';
GM_addStyle(`
.CommentBox .comment_list .CommentItemSticker .comment_sticker_link .image {
/*height: 50px !important;*/
display: none;
}
.CommentBox .comment_list .CommentItemSticker {
display: none;
}
`);
function convertToRelativeTime(timeString) {
var time = new Date(timeString.replace(/\. /g, '-'));
var now = new Date();
var diffMilliseconds = now - time;
var diffSeconds = Math.floor(diffMilliseconds / 1000);
var diffMinutes = Math.floor(diffSeconds / 60);
var diffHours = Math.floor(diffMinutes / 60);
var diffDays = Math.floor(diffHours / 24);
if (diffSeconds < 60) {
return '방금 전';
} else if (diffMinutes < 60) {
return diffMinutes + '분 전';
} else if (diffHours < 24) {
return diffHours + '시간 전';
} else if (diffDays === 1 && now.getDate() === time.getDate()) {
return '어제';
} else if (diffDays < 7) {
return diffDays + '일 전';
} else {
var monthNames = ["1월", "2월", "3월", "4월", "5월", "6월",
"7월", "8월", "9월", "10월", "11월", "12월"];
return time.getDate() + ' ' + monthNames[time.getMonth()];
}
}
function getReadableTime(item) {
var commentInfoDateElement = item.querySelector('span.comment_info_date:not(.done)');
if (commentInfoDateElement) {
var inputTime = commentInfoDateElement.textContent.trim();
var formattedTime = inputTime.replace(/(\d{4})\.(\d{2})\.(\d{2})\. (\d{2}):(\d{2})/, '$1-$2-$3T$4:$5:00');
var relativeTime = convertToRelativeTime(formattedTime);
commentInfoDateElement.textContent = relativeTime;
commentInfoDateElement.setAttribute('title',`${inputTime}`);
commentInfoDateElement.classList.add('done');
}
}
function checkDynamicElements() {
var commentItems = document.querySelectorAll('.CommentItem');
commentItems.forEach(function(item) {
var textComment = item.querySelector('.text_comment');
if (!textComment || textComment.textContent.trim() === '') {
item.style.display = 'none';
} else {
item.style.display = 'block';
}
getReadableTime(item);
});
}
var mutationCallback = function(mutationsList, observer) {
checkDynamicElements();
};
var observer = new MutationObserver(mutationCallback);
var targetNode = document.body;
var config = { childList: true, subtree: true };
observer.observe(targetNode, config);
})();