kone
소미소프트

소미소프트

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

07/28/2025, 04:59:26
유틸
2594 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.(수정추가) 미리보기 이미지 게시글 이동시에도 남아있는 오류 수정
Poriuretan 수영부의 에이스
동인
uzaki
04/25 15345 37
Poriuretan 여름 해변에서 의기투합
동인
uzaki
04/25 18067 48
Poriuretan 시골누나
동인
uzaki
04/25 16306 46
Poriuretan 선생님
동인
uzaki
04/25 13292 31
Poriuretan 옆방의 아주머니
동인
uzaki
04/25 14136 28
Poriuretan 정오가 지난 오후의 단지아내
동인
uzaki
04/25 15608 30
Poriuretan 폭풍전의 도서실
동인
uzaki
04/25 11673 28
Poriuretan 장마철의 빨래방
동인
uzaki
04/25 11448 43
Poriuretan 갸루b의 파파카츠
동인
uzaki
04/25 12749 60
[미번][번역요청] 디펜드 다이어리~_ver1.02
미번
minki
04/25 21063 27
[미번] RJ01612483,RJ01414102
미번
페비
04/25 55685 261
[요청복구] RJ01412500 Night High 5
미번
아무일도없었다
04/25 19518 37
기번) 더블 유부녀(미검수)
번역
썩은동태눈깔맨
04/25 32181 106
특공위원회 오우카 RPG 0 이미지(ui) 번역 80% 진행
작업현황
joyed47106
04/25 7303 19
[한국어 자막판][구매보급][전편느긋오호】 다우너 오호고에 개변태 후배와 섹스라이프
소리
이름뭐하지
04/25 19608 69
[미번] 비주얼노벨계 야겜 11개
미번
미스터장
04/25 19442 92
기번) BBC×FAMILY~
번역
썩은동태눈깔맨
04/25 42925 215
(요청복구) 테러블 레버토리 v1.01
복구
kakinara12
04/25 39313 62
고블린 네스트 세이브 최신화 완
세이브
흰꼴뚜기
04/25 8658 15
RJ388166 에이전트 시리우스 DLC
복구
doritori
04/25 28018 63
개꽂혀서 최소 10시간 이상 박았던 게임들
후기 및 공략
dpgutlqkf
04/25 30245 82
~임신 전설~ 옛 용사인 나와 초변태 폭유 공주님×3의 모유 듬뿍 임신시키기 아이 만들기 마왕 봉인 전설♪
소리
dasdaa
04/25 23359 109
후타, 명방) [직번] 시한테 박는 니엔
동인
wa4231
04/25 16082 94
[구매보급]【사상 최고의 오호신음】몰락 메스가키 영애 음문 조교
소리
이름뭐하지
04/25 13374 63
(요청복구) カーテンのむこう NTR 커튼 너머 NTR ver.1.8
복구
sinryeong
04/25 28188 90
[기번] 사신상관EX+DLC 2.0.02
번역
풍수식노천탕
04/25 52306 185
(요청복구) 무치 무치 자매 환생 목적지에서 변태 봉사 생활
복구
sinryeong
04/25 21139 67
메르시 (오버워치)
영상
브레머튼
04/25 19891 101
(청아) 꾸준 연필 30주차
창작
지나가던사람
04/25 17269 28
[AI번역] [JUNN] 네토라레바에 - 인싸 여친의 SNS 네토라레 기록 2
동인
gkcuwuwlltnnrra
04/25 44611 153