kone
소미소프트

소미소프트

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

07/28/2025, 04:59:26
유틸
2610 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.(수정추가) 미리보기 이미지 게시글 이동시에도 남아있는 오류 수정
88. AI, 블아) 히비키의 응원
야짤
miso5
05/20 8420 63
[번역 요청] 님포마니아 프리스트 최신작
미번
handk-02
05/20 8286 25
[구매보급] [버전업] [자체한글] RJ01169914 시니시스터2 SiNiSistar2 1.31? 26.05.20
번역
gkqisq
05/20 34519 205
[구매보급] [버전업] RJ01616268 종말의 얼터에고이즘 dlc만 2.02
미번
gkqisq
05/20 11442 31
[요청복구] 딸 납치하고 최면순애
복구
doritori
05/20 28726 81
미검수, AI역식) [Sage joh] 숨겨진 사연이 있는 엑소시스트와 환생악마의 치명적인 사랑
동인
sexe1
05/20 13195 57
[구매보급]【오호 성교미 특화】 강아지와 성활♡ 1+2+3편
소리
이름뭐하지
05/20 16106 81
(AI 번역 노모) [Onaka] 性愛カンケイ / 육체적 관계
동인
macross7
05/20 18611 51
RJ01568844 The Witchs End
복구
절대불멸
05/20 24780 66
큰 거 들어간다.
작업현황
mybest
05/20 6447 16
niwarhythm-천재 격투가의 패배
동인
k8625
05/20 19686 74
(노모 패치, 수정3) [VJ014099] 좀 더! 임신! 불꽃의 가슴 초 에로♡어플 학원!
번역
joyed47106
05/20 61003 544
Kase Daiki-10살어린 사촌동생
동인
k8625
05/20 37603 310
직번) 내가 동경하던 히어로가 여자가 되어 양아치한테 타락하는 이야기
동인
미식이네
05/20 22890 117
[복구] 특명소녀 아이기스 블루 1~13
복구
doritori
05/20 13938 57
eGlhbmd3ZWl0dWRvdQ 26년 4월까지
영상
karatro
05/20 22673 129
(청아) [Kotee] 이리야 일행이 최면술에 걸린 척하고 로리콘 돼지 약자남성소추아저씨에게 인지불필요 러브러브 임신 교배 강간당해서 수정하는 책
동인
밤하늘의신비
05/20 26637 164
Nekoshoko 작가 잘보고 있었는데
야짤
ㅇㅇ
05/20 10100 36
망가 뷰어 사이트 새로 만들었어요
작업현황
hiromi
05/20 8791 91
Nekoshoko-레이프 합법화~아나운서 가슴 일기예보!
동인
k8625
05/20 29983 120
Nekoshoko-거유로리소녀 모음
동인
k8625
05/20 29190 155
Raidon-화내지마 호시카와 1~3
동인
k8625
05/20 20832 153
모니에 (명조)
영상
브레머튼
05/20 20973 96
약간 스포) 사타니 카스미는 당신이 없으면 살아갈 수 없어 121일차 후기
후기 및 공략
Nate Higgerson
05/20 8245 15
[구매 보급] Re:IA 모음집
영상
bluescreen
05/20 39544 327
ai 아카메가 벤다)잠입작전중 포획당해 감금조교당하는 첼시
야짤
ezmood
05/20 11671 69
[후타주의] 귤복복 & 의현 (ZZZ)
영상
브레머튼
05/20 24392 106
AI) GPT로 뽑는 H 스테이터스 화면에 회상 시스템 비슷한 걸 구현함
야짤
날개 로봇
05/20 10506 31
jellfish 주문하신 아스나입니다.
동인
굴라그의죄수
05/20 18174 31
ai, 붕스) 스파클이 자꾸 유혹해서 마구 질내사정 해줬다
야짤
kjh9304
05/20 10034 116