kone
소미소프트

소미소프트

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

07/28/2025, 04:59:26
유틸
2699 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.(수정추가) 미리보기 이미지 게시글 이동시에도 남아있는 오류 수정
케모노 비슷무리한 사이트 찾음(영상+pc19게임파일+ASMR)
정보
playhsui
05/12 20728 144
[구매보급][베개 추천]최강의♀(암컷)는 당신의 신부♪ 저음 마왕님은 모든것을 용서해준다
소리
이름뭐하지
05/12 11973 79
[ai번역-쿠리후쿠 미노루] STOP!! 시간 정지 능력으로 꼼짝 못 하는 소녀들에게 미친듯 사정하는 사건
동인
mybest
05/12 27646 88
ai) 제로의 사역마 발정난 공주
야짤
Ghost
05/12 18097 19
[ai노모번역-에츠잔 자쿠수이] 정사에 물든다
동인
mybest
05/12 10522 36
플래피ー!
동인
hatlatal
05/12 13925 44
ai) 나히아 요로즈
야짤
Ghost
05/12 8213 19
[ai번역-히가시고 미칸] 젖내음 물씬 여름방학
동인
mybest
05/12 16259 37
길가던 여자애 잡아서 유두 피어스 박기
야짤
toscana
05/12 16433 40
수컷콜라보
동인
hatlatal
05/12 16791 37
비가 그칠 때까지만
동인
hatlatal
05/12 29096 99
[ai번역]옆집의 츤데레 서큐버스 아가씨
동인
mybest
05/12 15373 57
언리얼엔진 파일추출만 하는방법 정리
정보
boids
05/12 6337 16
[ai번역-비피더스] 성관계 여관
동인
mybest
05/12 15140 55
[5/12] 유라 (원신) 미니 HMV
영상
브레머튼
05/12 23274 88
[직번] [Xiong Ling] 호시노 루코 상식개변
동인
maha1004
05/12 24157 35
[손번역 Ver.0.21] Daily Lives My Countryside 0.3.4.3
번역
감자떡사요
05/12 48778 215
[스타레일] NO.070 은랑 ( 기본 + 후타)
영상
브레머튼
05/12 18861 111
요청복구) RJ01456652 완전 치○ - 내성적인 J○가 타락할 때까지
복구
ㅇㅇ
05/12 35954 54
구매보급 PUBPET
Mock
05/12 46458 118
ai, 붕스) 히메코에게 성처리를 부탁해 보았다
야짤
kjh9304
05/12 18993 129
[이미지번역 100%] Daily Lives of My Countryside v0.3.4.3
작업현황
dodoph123
05/11 13474 30
이미지 다운로더 만들어봄
유틸
lordofcinder
05/11 7908 34
[요청복구] 인공 학원 2
복구
이상성애
05/11 24556 74
[미번] 미번 일겜 8개 + 미번 양겜 6개
미번
미스터장
05/11 16171 61
んぴゅ・ゔぃむぞ 세미 롱 짱
동인
SK
05/11 62458 407
[구매보급]최○ 조교×백합 여고생/남자 싫어하는 레즈 커플을 방과 후 강○ 봉사
소리
이름뭐하지
05/11 18081 65
[미번][번역요청] 기도 소녀 샬롯 외 두개
미번
minki
05/11 7600 22
(요청복구) 사교의 포로 노모패치적용
복구
sinryeong
05/11 26046 74
[미검수][RJ227638]나의 H한 여름의 추억 ~누나들과 보낸 8월~
복구
돈키호테가조아
05/11 24206 106