kone
소미소프트

소미소프트

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

07/28/2025, 04:59:26
유틸
2649 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.(수정추가) 미리보기 이미지 게시글 이동시에도 남아있는 오류 수정
스타메이커 스토리 신소식
정보
handoro
04/30 10149 19
[미번] 수영부 고문 선생 쿤니편 part.1
동인
츠바키미유
04/30 18762 35
[미번] 미번 일겜 9개 + 미번 양겜 3개
미번
미스터장
04/30 18811 66
[복구] [미번,구매보급] [료나] RJ01543217 벌주기 소녀들 R (おしおき娘々R) v1.3+ 동일 서클 전작 4개
미번
r4gsdrg
04/30 14910 39
타락하지 않는 마녀와 걱정 많은 길마군 4월 기사
정보
미식이네
04/30 18335 36
[미번] Sword Art Online The Trap of Breath Concealed Magic ver.β6 (26.04.30)
미번
미스터장
04/30 19997 76
ai) NTR 접대골프 2
야짤
ai0098
04/30 16136 89
[미번] 어떤 부부의 반제(변제) 계획 ver.26.04.22 + DLC ver.26.04.11
미번
미스터장
04/30 18127 58
AI번역)[Shiwasu no okina] 이 학교의 모든 여학생의 윗입과 아랫입은 무한 친교라는 걸 알고 있는 사람은 나뿐?! 2편 (음모 有/無)
동인
allooww
04/30 45180 165
AI번역)[sasamori tomoe] 게이밍 하렘 5
동인
allooww
04/30 30349 139
직번) [Minamida Usuke] 성의의 증명 (식질 조언 구함)
동인
qlalfsla
04/30 22507 47
재밌는거 만들어옴
영상
ㅇㅇ
04/30 29505 197
AI, 셀레스포니아) 후배랑 백합
야짤
miso5
04/30 11442 98
구매보급) 사정 참기 데스게임 ~ 사정하면 죽는 남자 vs 사정시키지 않으면 죽는 여자 ~
동인
GOOD
04/30 28879 62
에노키후 서클근황
정보
sorbe123
04/30 6985 20
TU1EdHlwZTg3 모음집 업데이트 알림
영상
hannanas
04/30 22036 51
[구매보급,번역요청] (보추,게이,후타) 1분간 항문 섹스 하지 않으면 자지가 되는 RPG 1.02
미번
모모
04/30 9532 15
[미번/구매보급] [Shiwasu no okina] 이 학교의 모든 여학생의 윗입과 아랫입은 무한 친교라는 걸 알고 있는 사람은 나뿐?! 2편 (음모 有/無)
동인
04/30 16475 21
구매보급) 방과후의 술래잡기
번역
화앨
04/30 53273 192
[번역] (개씨발 존나 심한 닭장 주의 주의) [Tawara Hiryuu] 성처리 의무화 세계 1~9
동인
아줌마좋아
04/30 29896 135
[수간 + 이종간] 질 발렌타인 & 좀비견 & 네메시스 (바이오하자드)
영상
브레머튼
04/30 25563 80
비의 괴물 속편 제작중
정보
nyamberry
04/30 11038 31
deyui 모음집 재업
영상
moka413
04/30 26721 147
구매보급) 우리 반의 그라비아 아이돌이 절륜 자◯에 함락될 때까지
동인
GOOD
04/30 30378 77
체인소맨
영상
브레머튼
04/30 19669 94
직번)[Gonza] 나만의 농익은 아내 (45) ~나이 차이 따위~(하)~
동인
dresss
04/30 12595 72
UGlndGFyb3Rhcm8= 3개자막 맹글어옴
영상
gombobest
04/30 17402 83
[구매보급/NTR] 소꿉친구 여고생 여친의 NTR 보고【굉음 오호 소리】
소리
오호이야
04/30 12207 82
[요청 복구] 시니시스타 2 폭유모드
복구
kk0101
04/30 28068 69
유부녀 세리아의 타락과 배덕 발매일 결정
정보
nyamberry
04/30 5855 24