kone
소미소프트

소미소프트

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

07/28/2025, 04:59:26
유틸
2672 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 동거 1개월
동인
uzaki
05/01 20873 75
Poriuretan 집에서 술마시며 보내는 크리스마스
동인
uzaki
05/01 19986 47
Poriuretan 갸루하고 엘리베이터에 갇혀버렸다
동인
uzaki
05/01 19746 40
Poriuretan 어느 p활 여자
동인
uzaki
05/01 13425 28
Poriuretan 보건실의 선생님
동인
uzaki
05/01 10490 35
Poriuretan 트릭 오어 트릿 2022
동인
uzaki
05/01 11329 52
Poriuretan 쿨한제자
동인
uzaki
05/01 16110 51
[ai번역] RJ01591409 구련휘정 퀄터 아르미네스 & 탄젤
번역
gre0204
05/01 54293 282
[구매보급]【한국어 자막판】 길 잃은 숲에서 폭유 엘프 자매에게 구조되었지만... 결국 잡아먹혔습니다♪
소리
이름뭐하지
05/01 11183 80
Poriuretan 네토라세 입문
동인
uzaki
05/01 12787 42
Poriuretan 제멋대로인 여자친구
동인
uzaki
05/01 10745 46
[요청복구]노예 공주 엘리자
복구
ㅇㅇ
05/01 32049 58
번역) [♀こみ] 마리 인생 종료 최면
동인
cyberse
05/01 19194 55
RJ01613299 번역하는 중
작업현황
norin021
05/01 8594 63
[재업][chalies] 이 자식이! (냥코대전쟁 동인지)
동인
ashgray
05/01 11953 46
구매보급) eGlhb2NodW4= 작가 유부녀섹스파티 1~17
영상
경계선상
05/01 30402 137
Napo 사랑의 랭크 매치
동인
SK
05/01 18298 94
카프카 & 히메코 & 은랑 '섹스 파티'
영상
브레머튼
05/01 16757 99
이젠 vpn 상시로 키는게 디폴트가 되겠네
일반
아나스타샤
05/01 9640 20
mmd 자작영상 공유 2
영상
pst0025
05/01 10622 53
[구매보급, 자체한글번역] 여우 마을의 수호전
번역
saika
05/01 63270 290
AI) 래빗홀 미쿠
야짤
miso5
05/01 10162 100
[Shirabe Shiki] 대음마전에 있어서 감각 차단 부적은 필수 대비책입니다 ① (캐릭터 디자인 변경)
동인
티모
05/01 33290 136
90일, 26.05.02, 1.11 GB) RJ01517134 3D Custom Okazu Maker mono Auto ko.7z
번역
ㅇㅇ
05/01 43472 122
[ai번역] RJ01591409 구련휘정 쿠르타 아르미네스 & 탄젤 EG (1.0.0d) v3(20260503)
번역
mowajelly
05/01 42117 246
[Liyoosa] 도련님께 음문이 새겨진 채 천천히 길들여지는 메이드
동인
요요코코
05/01 23570 136
[복구] pin-point사 작품 6개 ai 번역
복구
karatro
05/01 31081 83
90일) RJ01474906 Tentacle Game v.1.1 mono Auto ko.7z
번역
ㅇㅇ
05/01 33628 130
이와라 차단먹은김에 브픈서버 만들었다
일반
kiffufuf
05/01 8973 32
히카리나이토anomarin9 4월영상
영상
001245
05/01 22978 84