kone
소미소프트

소미소프트

미리보기 관련 유저스크립트

07/28/2025, 04:59:26
유틸
2588 views · 3 likes

미리보기 사진 위치나 크기 조정이 필요하다 생각해서 만듬 필요한 사람 쓰셈

+25/07/28 19:53분 수정 게시글 클릭시 미리보기 이미지 남아있는 문제 해결

// ==UserScript==
// @name         코네 미리보기 조정
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  kone.gg 미리보기 복제 방식으로 위치와 크기 자유 조정 + 게시글 밖 잘림 방지 + 원본 숨김 처리 포함 + SPA 대응
// @author       cloud67p
// @match        https://kone.gg/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function () {
  'use strict';
  
  let activePreview = null;
  let hiddenOriginal = null;
  let currentUrl = window.location.href;

  // 미리보기 정리 함수
  function cleanupPreview() {
    if (activePreview) {
      activePreview.remove();
      activePreview = null;
    }
    if (hiddenOriginal) {
      hiddenOriginal.style.display = '';
      hiddenOriginal = null;
    }
  }

  // URL 변경 감지 (SPA 대응)
  function detectUrlChange() {
    const newUrl = window.location.href;
    if (newUrl !== currentUrl) {
      currentUrl = newUrl;
      cleanupPreview();
    }
  }

  // URL 변경 감지를 위한 이벤트 리스너들
  window.addEventListener('popstate', cleanupPreview);
  
  // pushState, replaceState 감지 (SPA 라우팅)
  const originalPushState = history.pushState;
  const originalReplaceState = history.replaceState;
  
  history.pushState = function() {
    originalPushState.apply(history, arguments);
    cleanupPreview();
  };
  
  history.replaceState = function() {
    originalReplaceState.apply(history, arguments);
    cleanupPreview();
  };

  // 주기적으로 URL 변경 체크 (추가 안전장치)
  setInterval(detectUrlChange, 100);

  // 클릭 이벤트 감지 (게시글 링크 클릭 등)
  document.addEventListener('click', (e) => {
    // 링크나 버튼 클릭 시 미리보기 정리
    if (e.target.closest('a') || e.target.closest('button') || e.target.closest('[role="button"]')) {
      cleanupPreview();
    }
  }, true);

  // 키보드 이벤트 감지 (ESC 키 등)
  document.addEventListener('keydown', (e) => {
    if (e.key === 'Escape') {
      cleanupPreview();
    }
  });

  // 기존 마우스오버 이벤트
  document.addEventListener('mouseover', (e) => {
    const postWrapper = e.target.closest('.group\\/post-wrapper');
    if (!postWrapper) return;
    
    const preview = postWrapper.querySelector('.group-hover\\/post-wrapper\\:block');
    if (!preview) return;
    
    // 기존 미리보기 정리
    cleanupPreview();
    
    // 원본 숨김
    preview.style.display = 'none';
    hiddenOriginal = preview;
    
    // 복제본 생성
    const clone = preview.cloneNode(true);
    const rect = postWrapper.getBoundingClientRect();
    
    clone.style.position = 'fixed';
    clone.style.left = '40rem';
    clone.style.top = `${rect.top - 200}px`;
    clone.style.zIndex = '9999';
    clone.style.pointerEvents = 'none';
    clone.style.display = 'block';
    
    const img = clone.querySelector('img');
    if (img) {
      img.className = '';
      img.style.width = 'auto';
      img.style.height = 'auto';
      img.style.maxWidth = '720px';
      img.style.maxHeight = '720px';
      img.style.objectFit = 'contain';
      img.style.display = 'block';
    }
    
    document.body.appendChild(clone);
    activePreview = clone;
  });

  // 기존 마우스아웃 이벤트
  document.addEventListener('mouseout', (e) => {
    const postWrapper = e.target.closest('.group\\/post-wrapper');
    const related = e.relatedTarget?.closest?.('.group\\/post-wrapper');
    
    if (postWrapper && related !== postWrapper) {
      cleanupPreview();
    }
  });

  // 페이지 언로드 시 정리
  window.addEventListener('beforeunload', cleanupPreview);
  
  // 페이지 숨김 시 정리 (탭 전환 등)
  document.addEventListener('visibilitychange', () => {
    if (document.hidden) {
      cleanupPreview();
    }
  });

})();
3
1 comment
07/28/25 Edited 07/28/25
1. 미리보기가 게시글 제목을 가림 -> 위치를 더 오른쪽으로 보냄 2. 미리보기 더 크게 보고싶은데 단순히 크기 조정시 -> 게시글 박스를 넘어가면 짤림 -> 새로 복제함 3. 크기 더 크게 만드니 맨 아래 게시글의 미리보기는 하단부가 짤림 -> 미리보기들을 전부 위로 좀 더 올림 4.(수정추가) 미리보기 이미지 게시글 이동시에도 남아있는 오류 수정
MMD 모션,음악 통팩 공유
유틸
pst0025
04/26 9316 56
미번,구매보급) 러브러브에치시뮬레이션(live 2d)
미번
lalolo
04/26 11431 32
AI, 셀레스포니아) 가짜에게 지고 벽엉덩이
야짤
miso5
04/26 15302 156
[AI번역][미검수] RJ01045491 [happypink] 최면의 공주기사 ver1.092
번역
coupon
04/26 52362 174
[업데이트 안내] 간호사 콜 경비원 +DLC1 v1.26.4.24 (자칭 : 자택경비원3)
번역
kkkkkk0909
04/26 42966 171
[Nunnu] Funny Fuck! | 퍼니 퍽!
동인
kifbodo245
04/26 15670 57
(청아 NTR 후타 등) 오오랜만에 다시 들고 와쓰
영상
bisesdop
04/26 36076 180
[업데이트 안내] 존재감 없는 여동생과의 소박한 일상 1.08rev.3
번역
kkkkkk0909
04/26 38591 118
[Togami] 분홍빛 여우 색기의 술! ~무참히 패배한 암여우의 임신 묘상화~
동인
ashgray
04/26 23570 117
[미번,구매보급] RJ01605204 ゆりかごのプエルステラ
미번
sfman6348
04/26 17803 34
RJ01412500 NightHigh5 mono Auto ko.7z
번역
ㅇㅇ
04/26 29685 98
6Zu25pum6JOd6Z+z 작가 영상 2개
영상
asd0222
04/26 14644 57
[Almondman] 마마 선생님들과 러브러브 놀이 시간
동인
멜신
04/26 32442 247
[구매보급]【패배메스타락특화】복수의 쿠노이치 아야메 굴욕의 패배 절정
소리
이름뭐하지
04/26 12446 72
[AI번역]음모일기 8+ 순애편
동인
mobilejoara
04/26 23197 36
[harusawa] 나를 좋아하는 문학여친이 NTR 섹파에게 범해져 타락하기까지
동인
agnet666
04/26 22642 35
[수정1][AI번역][미검수] RJ437935 성활 Hotel v1.0.3
번역
ㅇㅇ
04/25 43504 151
(노모화) [Shiwasu No Okina] 100번 차여버린 인기없는 나를 불쌍히 여겨준 남친 있는 여자사람 친구가...
동인
xbox
04/25 51813 289
Poriuretan 산악 드라이브에서 의기투합
동인
uzaki
04/25 23938 64
Poriuretan 친구네 누나
동인
uzaki
04/25 35402 91
Poriuretan 보란듯이 보여줌
동인
uzaki
04/25 24560 62
Poriuretan 노출증 환자의 할로윈
동인
uzaki
04/25 15601 45
Poriuretan 냄새 페티시
동인
uzaki
04/25 16310 39
돌보기 좋아하는 엄마, 아들한테 박혀버리다
동인
haroishi
04/25 25118 63
Poriuretan 들이닥친 갸루 a (무삭제 판)
동인
uzaki
04/25 25820 52
Poriuretan 아이의 씨를 원하는 유부녀
동인
uzaki
04/25 18506 35
Poriuretan 선배의 선택
동인
uzaki
04/25 17682 37
Poriuretan 보이시한 소꿉친구
동인
uzaki
04/25 20805 28
Poriuretan 세련된 선도부원
동인
uzaki
04/25 18122 34
Poriuretan 유부녀 요가 피트니스 (무삭제판)
동인
uzaki
04/25 21354 35