kone
소미소프트

소미소프트

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

07/28/2025, 04:59:26
유틸
2536 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.(수정추가) 미리보기 이미지 게시글 이동시에도 남아있는 오류 수정
미끼치한수사관 리나 꼭지 맞추기 게임 개선(?) 모드 v0.2.1
유틸
ltony
05/13 10653 12
(수정 기능 추가) 동인지 볼 때 쓰려고 만든 자동 스크롤 뷰어???
유틸
ATTAA
05/12 15808 6
비월선행록 CommonEvents.js 누락 수정 패치
유틸
kangjang
05/12 10466 14
QW1wbGVjdGVk 블렌더 파일 공유 두번째 4.72GB
유틸
hannanas
05/12 9436 13
QW1wbGVjdGVk 블렌더 파일 공유 첫번째 9.74GB
유틸
hannanas
05/12 15637 21
이미지 다운로더 만들어봄
유틸
lordofcinder
05/11 7888 34
[LM Studio + RPG Maker MVMZ] LMTranslator [쯔꾸르 다국어 번역기]
유틸
전적노트
05/11 14005 9
코캇 명조 히유키 프리셋 2종류
유틸
pst0025
05/09 15990 24
(코이카츠) 씬 카드 공유
유틸
pst0025
05/09 9214 44
시니시스타2 안대 금발녀 모드 1.2.1 ver
유틸
cascastu
05/08 14527 37
[후타]pernio의 후타나리 시리즈 노모패치 모음(요청복구)
유틸
레가토
05/07 4588 6
자동소미 해적판X2 1.0.4업데이트 알림
유틸
스눕제이크
05/07 6572 18
[★추천] 무료 망가 번역기★
유틸
mybest
05/07 27900 127
(코이카츠) 소전 캐릭 2명 프리셋
유틸
pst0025
05/06 6941 21
(코이카츠) 명조 신캐 둘 프리셋
유틸
pst0025
05/06 6583 37
미끼 치한 수사관 리나 유저 모드 (직접 만듬)
유틸
a2343212
05/06 8110 14
Unity Texture Changer v1.0
유틸
kumarin
05/05 7594 34
90일) VX, VXA 개선용 스크립트 +@
유틸
ㅇㅇ
05/05 3879 8
(코이카츠) 버튜버 프리셋 공유
유틸
pst0025
05/05 17144 79
염월선행록 translation-cache.log 5월10일자 갱신 마지막
유틸
보바도사
05/04 8876 39
배덕의 달콤함에 물든 마나카 FansChat 마개조 및 번역 모드 WIP Manaka
유틸
sco0815
05/04 12281 57
파일 구글 or LM 번역기) AI_kr_tr_9.pyw, AI_kr_tr_8.pyw
유틸
ㅇㅇ
05/03 11634 20
⚠️⚠️멀웨어 탐지 스크립트 (신종 RAT) - 260502⚠️⚠️
유틸
moomin
05/02 17496 103
RPG Maker MV/MZ 실시간 번역기 3.1 (구동휘정3 대응 -3)
유틸
mrpls
04/30 17248 36
[오류패치] 섬홍의 아리에스 1.21 db 오류에 대한 패치 (패치만 있음)
유틸
aquapre
04/30 4410 12
게임을 윈도우 샌드박스 안에서 실행하는 스크립트 (악성코드 대책)
유틸
mrpls
04/30 7363 19
[노모파일, AI] 파치몬 -8bit MONSTER-
유틸
soxocel777
04/29 20451 56
동음 폴더 정리기
유틸
안리체
04/28 7293 7
자동 소미 해적판의 해적판의 해적판 (260503 13:58 v1.3.5 업데이트)
유틸
bellbell
04/28 13579 38
사신상관 치트앤진 치트 테이블(수정3)
유틸
ㅇㅇ
04/28 10774 7