kone
소미소프트

소미소프트

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

07/28/2025, 04:59:26
유틸
2710 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.(수정추가) 미리보기 이미지 게시글 이동시에도 남아있는 오류 수정
ai,청아,버튜버)코코로쨩 마이크로비키니
야짤
gpsel157
05/12 19548 26
이전에 가지고 있던 것 복구(10개)
복구
ziririri123
05/12 51831 169
[LYCO]리오&토키 처벌쇼
영상
ㅇㅇ
05/12 35613 83
古い(furui) 모음
영상
쀏꿱이
05/12 35826 159
ガナイショウ(가나이쇼우) 26.3. 눈나
야짤
kuuki
05/12 11004 41
회복술사의 재시작 서비스씬 모음
영상
고죠/센세
05/12 42222 206
[90일복구] 요청자료 5종
복구
Ghost
05/12 42461 110
[AI번역/초반검수] 쾌락의 저주(The Curse of Pleasure) v1.0
번역
weller703
05/12 72803 245
대리업로드 번역게임 6개
번역
미스터장
05/12 77271 246
[한글자막] [NightHawk(ナイトホーク)] incest village インセストヴィレッジ
영상
lximiad
05/12 30537 73
Ai번역) 여동생의 친구가 동경하던 G컵 갸루 코스플레이어였던 이야기 2
동인
customer121
05/12 29665 180
[구매보급] [버전업] RJ01452526 이상적인 히키코모리 생활 ~부녀의 꽁냥꽁냥 동거~ 1.1.6 26.05.12 "26.05.22(수정)"
번역
gkqisq
05/12 35018 174
[GIF] (후타, 보추, 수?간 포함) QW1wbGVjdGVk gif 모음집
야짤
hannanas
05/12 14783 47
AI, 셀레스포니아) 아마네 데이트편
야짤
miso5
05/12 12001 112
[버전업] [구매보급] RJ01588884 이노센트 도터 v1.1.1
미번
gkqisq
05/12 11726 45
QW1wbGVjdGVk 모음집 없데이트 알림
영상
hannanas
05/12 23938 81
[구매보급] RJ432000 성처리가 있는 학교 2023.04.26
미번
gkqisq
05/12 17199 35
(요청복구, 미검수) Cursed Armor 2
복구
zeri1590
05/12 18307 49
[미번] 오네쇼타 마을의 엣치한 여름방학 스팀 노모 일어판
미번
미스터장
05/12 10217 44
[atahuta] 발정기 한창 오나홀 씨.
동인
ㅇㅇ
05/12 42966 276
[Croriin/노모] 마녀가 아끼는 것
동인
ㅇㅇ
05/12 25370 160
감각 차단 암컷화 트랩! 손번역 및 노모작업 현황
작업현황
미스터장
05/12 12416 36
[ai번역=오오토리 마히로] 나의 이세계 하렘 1
동인
mybest
05/12 17081 42
[유부녀/레이프/밀프쇼타/서양](보루토) 히나타의 숨겨진 욕망
영상
Ghost
05/12 29568 117
[한글자막] 미시 여교사, 쇼타 사정 도와주기 (上편)
영상
실루엣21
05/12 18592 97
QW1wbGVjdGVk 블렌더 파일 공유 첫번째 9.74GB
유틸
hannanas
05/12 15647 21
[bWlyYWNhbg== / RJ01602232] 전생 용사가 즉시 함락 마법으로 이세계 무쌍!! [전편]
영상
yozuna
05/12 26859 178
요몽원 이미지 번역하면 수요 있나?
일반
losress
05/12 6025 55
미번) [airu] 폭유에 엉덩이가 커다란 흑장발 무녀씨에게 사랑이 무거운 개변태봉사로 쥐어짜인다
동인
hun99
05/12 14122 26
[AI/이미지번역] Esurience 일본풍 미인 소꿉친구와 숨겨진 갈망
번역
미식이네
05/12 41568 168