kone
소미소프트

소미소프트

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

07/28/2025, 04:59:26
유틸
2717 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.(수정추가) 미리보기 이미지 게시글 이동시에도 남아있는 오류 수정
【극음】 비경의 숙면 에스테틱 살롱에 오신 것을 환영합니다~청초 테라피스트들과의 비밀 밀착 극상 코스~
소리
키리안
05/05 11406 64
[후타] 이본 & 관리자 파트 1 (엔드필드)
영상
브레머튼
05/05 17064 97
자궁문신 데니아 (명조)
영상
브레머튼
05/05 17748 120
아를레키노 & 츄츄족 (원신)
영상
브레머튼
05/05 23070 179
요청복구 - 【패배 무참 타락】쾌락 절정 여자닌자 유키메 ~내 임신술이 네놈의 잡졸에게 질 리가 없어~
소리
테탑시
05/05 10639 62
90일, 대리) RJ269944 FlashCyclingRide 2~자전거 노출주의보 v1.40.zip
복구
ㅇㅇ
05/05 15979 53
청아, AI번역) [직번] 전뇌에 잠든 사랑의 열쇠 3부 (Umiyamasoze)
동인
rapbit
05/05 12840 46
청아, AI번역) [직번] 전뇌에 잠든 사랑의 열쇠 2부 (Umiyamasoze)
동인
rapbit
05/05 10679 38
청아, AI번역) [직번] 전뇌에 잠든 사랑의 열쇠 1부 (Umiyamasoze)
동인
rapbit
05/05 23276 50
[구매보급]RJ01200916 Succubus&magic
미번
gnrjrdtjcft
05/05 17656 41
[미검수][AI][패치만] RJ01549336 알미오시온의 의술사
번역
lovesccubus
05/05 64485 218
란도셀 여친 ~아이가키 카논~ 〇학교 ⑤학년 ①⓪살 '오빠♪ 어른이 하는 야한 일♪ 〇학생인 나에게 알려줘'
소리
9ya
05/05 14053 47
[ai 자동채색 작업] Rama 나, 여자가 되어버렸어… 작업 현황
야짤
fhfhfghdr453
05/05 9599 25
로리 마법소녀의 1주일 조교일기 2 , 3
소리
9ya
05/05 8995 50
[인간 번역] (RJ01610735) 一人暮ぐらしの夏休み
번역
Jack
05/05 77489 310
[구매보급]무지천사를 애완동물화~피네는인간의 정액변소가 되었습니다♡~
소리
이름뭐하지
05/05 9099 67
Evening Survivor 1.1.35
미번
ㅇㅇ
05/05 8824 36
[구매보급/미번/촉수?/이종간/수간/충간]Crynaria: Tears In The Abyss
미번
루파조아
05/05 16704 72
[미번][번역요청]size me up
미번
819455
05/05 8521 28
디바 임무 실패
야짤
177523
05/05 12684 34
[요청복구] RJ01356929 청빈성녀 에로컬트에 빠지다
복구
20001
05/05 18566 46
[후원보급] (후타, 보추, 수?간 포함) QW1wbGVjdGVk 모음집
영상
hannanas
05/05 27468 102
오늘은 어린이날
야짤
ㅇㅇ
05/05 13326 44
[구매보급] RJ01602261 ReisenHDream
미번
souldeth
05/05 7119 20
빨간날 기념 재밌는거 만들어옴
영상
ㅇㅇ
05/05 24810 126
스포, 복구요청)"변태적인 시스템" 여고생 스파이 잠입 수사 성 음술학원 RJ01148691 후기
후기 및 공략
eooeooeoo
05/05 8232 18
[요청복구] NTR 모험가 리에나 -노려진 그녀와 작은 그 사람
복구
dk041633
05/05 33483 102
미번/구매보급 마도사카네데 후타나리던전 안드로이드 버전
llmulge25
05/05 26507 34
고어,료나)pain:rein 0.096v
번역
sngjw1kq
05/05 31980 71
26.05.06, 90일) 2. RJ223237 SEQUEL awake v1.10. 개선 26.05.06.7z
복구
ㅇㅇ
05/05 28326 79