kone
소미소프트

소미소프트

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

07/28/2025, 04:59:26
유틸
2504 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.(수정추가) 미리보기 이미지 게시글 이동시에도 남아있는 오류 수정
[일부 노모패치] 서큐버스 & 매직 (청아,언버스짤 있음)
유틸
OTGie
11/02/25 5635 26
[노모패치]신인마왕과 100명의 연인들
유틸
아르
11/02/25 10716 35
Anaertailin 작가의 Slay the Spire 모음집
유틸
삐뉴
11/01/25 26579 42
[노모 + 텍스쳐 패치] 여신 메르의 만지작 동거 성활 v1.0
유틸
털털털털털털털털
11/01/25 11648 67
무료 BGM 모음집 2025.11.01.
유틸
날개 로봇
11/01/25 4928 15
다시 돌아온 다키스트 던전 NSFW 완전판 [Npc 리텍 / 영웅 리텍 / 이쁜이쁜 영웅 모드 / 몬스터 리텍] + 새 모드!
유틸
삐뉴
10/30/25 21769 122
[노모패치] PRIMITIVE HEARTS (DMM판O, 스팀판X)
유틸
마나난
10/29/25 2310 7
슬레이 더 스파이어 (Slay The Spire) R18 패치 모드
유틸
cirial
10/28/25 27187 43
미끼 치한 수사관 리나 모드
유틸
happy123
10/27/25 10175 17
렌파이 갤러리 강제 오픈 스크립트
유틸
난민1호
10/27/25 2860 9
일라이자의 비약 노모(Decensor) 패치
유틸
이브라브
10/26/25 4825 25
압축파일 썸네일 확장
유틸
h-aszzcb
10/24/25 1897 9
코네 추천순 정렬 스크립트 업데이트
유틸
ducktail
10/24/25 12802 38
추출된 *.txt 파일 번역툴 ( 파워셀 코드)
유틸
lovesccubus
10/23/25 2041 5
코네 추천 컷 & 추천순 정렬 스크립트
유틸
ducktail
10/20/25 10756 59
[폰트파일] 네노토리 2.0에 들어있던 MsNanumGothicWK 폰트파일
유틸
katress
10/19/25 3170 6
MV/MZ 실시간 번역기 0.3 업데이트
유틸
moveit
10/18/25 6451 47
동인 런처 db활용 딸각 방주 이름 정리기 GUI판
유틸
asdf1243
10/16/25 3343 11
[노모이미지만][청아] 호문쿨루스와의 성생활 노모패치
유틸
Ghost
10/16/25 8976 64
RPG Maker MV, nwjs 프로필 오류 프레임 드랍 해결방법
유틸
rinsor
10/15/25 3346 14
동인런처 db 백업 기능을 활용한 방주이름 딸깍 정리기
유틸
asdf1243
10/14/25 2360 3
기번 누락 대사 검수 보조 툴 (Tsukuru Extractor 보조 툴)
유틸
bermuda
10/14/25 2246 11
오토소미 autosomi업뎃함
유틸
김머시기
10/13/25 8675 61
방주정리기 (파일명정리 프로그램) v1.16 (26.04.04)
유틸
알비노
10/12/25 14267 54
RPG Maker MV/MZ 실시간 번역기 (DeepL) - 셀레스포니아 3in1 외 기타등등 가능
유틸
moveit
10/11/25 12174 36
쯔꾸르[MV]MOG플러그인[MZ]SOR배틀링 파일 교환용 플러그인-1.3
유틸
brothers
10/11/25 1284 5
감옥용사 조이플 오류 패치파일
유틸
감비아
10/11/25 5685 6
자작 암호화된 링크 새탭으로 띄워주는 크롬 확장프로그램 공유
유틸
cx7175
10/11/25 2164 13
자작 히토미 다운로더 헬퍼 크롬 확장프로그램 공유
유틸
cx7175
10/10/25 4750 4
도나도나 미검열 CG 오류 수정 최종완성본final최종2
유틸
riel64
10/06/25 14827 77