kone
소미소프트

소미소프트

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

07/28/2025, 04:59:26
유틸
2503 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.(수정추가) 미리보기 이미지 게시글 이동시에도 남아있는 오류 수정
섀도우버스WB 카드 누패
유틸
나나바
05/27 1811 9
방주 해제 스크립트 공유
유틸
ddiff
05/26 2653 9
unholy maiden seed of profanity모드 1.4
유틸
leessss25
05/26 2099 13
[복구]섹타듀벨리 모드팩
유틸
continuereset
05/26 5138 20
[그냥복구/본체없음] 배덕의 달콤함에 물든 마나카. 여기서 받은 모드팩
유틸
루파조아
05/26 2999 9
FORTUNE BRIDE ~절정개안의 의식~ 노모 패치
유틸
미스터장
05/24 6503 33
(코이카츠) 엔드필드 프리셋 공유
유틸
pst0025
05/23 9006 65
EnigmaVBUnpacker (MV MZ 언팩) 웹버전 오픈
유틸
mrpls
05/23 4352 15
파일/ 압축/ 폴더 제목의 품번 괄호 삭제해주는 유틸
유틸
몬스터가아니다신이다
05/23 3070 2
[패치만] 시니시스타2 따거 MOD
유틸
하우두유두
05/22 14100 50
(수정 사항3)내가 쓸려고 만든 코드 검색용 + 파일관리
유틸
ATTAA
05/21 4063 14
[노모패치] 갓 딴 임신시키기 좋은 날
유틸
나나바
05/21 9868 39
zenpy 폰트 설치기
유틸
thxl23
05/20 3551 6
내가 쓸려고 만든 유틸 프로그램임
유틸
몬스터가아니다신이다
05/20 4176 6
내가 쓸려고 만든 DLsite 코드 검색 용
유틸
ATTAA
05/19 6002 7
내가 쓸려고 만든 유니티 버전별 폰트랑 어디서 구해온거 (오토트랜스용)
유틸
neighborsbear
05/19 6908 4
[요청복구] 감옥용사 1.20 조이플 구동패치
유틸
ssddttj
05/17 3285 5
누군가 쓸 마법의하나 マホウノハナ 0.9e 실시간 번역용 프리패쳐 파일
유틸
ㅇㅇ
05/17 7170 8
키리키리 엔진 ScnEditorGUI 개선판 (scn 암호화 파일 에디터)
유틸
joyed47106
05/16 6745 7
시니시스타 2 업뎃기념 모드 모음
유틸
sims9876
05/16 20931 105
(코이카츠) 버튜버 프리셋 공유 ver.2
유틸
pst0025
05/16 13363 51
(코이카츠) 버튜버 프리셋 공유 (복구)
유틸
pst0025
05/16 14813 64
WebP_Converter 코네 다운로드하다 WebP 불편해서 만든 프로그램
유틸
noname
05/15 13246 16
(코이카츠) 최근에 풀린 프리셋 공유
유틸
pst0025
05/15 12796 34
[RPG Maker MV/MZ 실시간 번역기] 4.0 출시
유틸
mrpls
05/15 22735 70
내가 쓰려고 만든 동음 정리 유틸
유틸
yeppi
05/15 8284 24
Texture Tool for Unity 6 ( Mono / IL2CPP ) v0.1.1 최초 배포 버전
유틸
argoklarke
05/14 15288 28
(코이카츠) 학원마스 프리셋 공유
유틸
pst0025
05/14 15686 43
(코이카츠) 프리셋 공유
유틸
pst0025
05/14 11585 58
comfyui를 이용해서 배경음을 식질해보자
유틸
프로베스트캣
05/14 20852 13