kone
소미소프트

소미소프트

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

07/28/2025, 04:59:26
유틸
2724 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.(수정추가) 미리보기 이미지 게시글 이동시에도 남아있는 오류 수정
(한글자막) 쉽게 휩쓸리는 폭유 메이드씨가 임신 할 때까지
영상
꽃사슴
05/06 22116 145
[기계번역] Love & Jealousy [Act 4]
번역
karuparu13
05/06 24442 77
[구매보급] [44Gv44GE44Gt ] 철도가키
영상
바람
05/06 34333 159
[5/5] 엽빛나 (ZZZ)
영상
브레머튼
05/06 13530 102
(한글자막) 쉽게 휩쓸리는 무뚝뚝한 폭유 아가씨가 임신 할 때까지
영상
꽃사슴
05/06 25851 141
[미번/번역요청][matsuzawa muni]Nikutai Hensai ~Shakkin Jigoku no China Musume~ | Debt Repayment In Kind
동인
오곡아줌마
05/06 11088 21
[한글패치]기계 소녀가 엮어내는 계보 vol.1-리오나의 착정 실험실_수정2
번역
아르
05/06 60113 164
[나의 히어로 아카데미아] 랙돌X데쿠
영상
Ghost
05/06 28092 141
[기번]Bondage Club
번역
브브븟
05/06 38289 170
🔞버그를 수정했고, 마지막 그림 공부를 했습니다.
창작
폭8맛
05/06 4538 17
Br@n)벽람항로 하우덴 리우 + 통합편집
영상
비밀봉투
05/06 14109 92
[구매보급]【저음 오호성】 무표정한 후배 - 엄청 야한 마코토의 구애 격렬한 절정 섹스
소리
이름뭐하지
05/06 9647 73
보추)[Locon]궁도 남자 총집편
동인
요요코코
05/06 15582 33
AI, 청아) 메스가키 참교육
야짤
miso5
05/06 14995 94
[구매보급]마성의 제자 - 아이 있는 교사를 사랑하는 천진난만한 여고생의 역 네토리
소리
이름뭐하지
05/06 7557 69
영화관에서 제인 도 & 와이즈 (ZZZ)
영상
브레머튼
05/06 13704 85
[귀 핧기 특화] 핥기 페티시 × 프린세스 ~귀 안쪽까지 "평생 너무 좋아"를 핧짝 흘려보내는 신혼 페로러브 밀착 아가 만들기~
소리
maruran
05/06 9022 81
[v1.286 patreon반영(5/7) , v1.282(5/6)] 비월선행록 번역파일만 [AI 직접 번역]
번역
handlejk
05/06 64545 298
[신작/4K48FPS] 고백 1
영상
쿠지락스
05/06 19185 137
[신작/4K48FPS] 성광섬희 포니 세레스 2
영상
쿠지락스
05/06 19372 162
[신작/4K48FPS] 나의 이상적인 이세계 생활 4
영상
쿠지락스
05/06 14231 168
[신작/4K48FPS] 쉬운 암컷들의 나날 2
영상
쿠지락스
05/06 26258 323
[신작/4K48FPS] 치매문릉 1
영상
쿠지락스
05/06 19302 225
[신작/4K48FPS] 레이카는 화려한 나의 여왕 3
영상
쿠지락스
05/06 12885 148
벨 (ZZZ)
영상
브레머튼
05/06 12881 95
[신작/4K48FPS] 끝내 아내가 되어 1
영상
쿠지락스
05/06 16084 140
[신작/4K48FPS] 사랑은 갸루에서 시작되는 운명 1
영상
쿠지락스
05/06 23447 224
[신작/4K48FPS] 거유 두 명이 없으면 안 서는 남편을 위해 친구를 데리고 온 아내 1,2
영상
쿠지락스
05/06 24231 409
(코이카츠) 소전 캐릭 2명 프리셋
유틸
pst0025
05/06 6941 21
오나홀 형태따기 샘플이 되어준 심술궂고 쿨한 후배OL의 조롱과 거짓신음 오나홓 대딸
소리
maruran
05/06 17620 79