kone
소미소프트

소미소프트

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

07/28/2025, 04:59:26
유틸
2721 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.(수정추가) 미리보기 이미지 게시글 이동시에도 남아있는 오류 수정
神の血:TheBloodofYidhra 발매 예고 개시
정보
도라야키
05/06 7240 20
AI, 블루아카, 청아) 키보토스의 무력
야짤
xepd5264
05/06 8196 19
[미번][구매보급][번역요청]NTR MOBILE v.0.23.0
미번
졸라급한마음
05/06 10042 23
(코이카츠) 명조 신캐 둘 프리셋
유틸
pst0025
05/06 6607 37
[복구] 레바테인 복구 영상
영상
브레머튼
05/06 14217 62
[구매보급]노예 소녀 티티와의 달콤한 공의존-노예 소녀를 잔뜩 응석받이로 만드는~
소리
이름뭐하지
05/06 8920 55
청아, AI번역) [직번] 요도확장 조교기록 (OKINA)
동인
rapbit
05/06 19687 41
(AI 이미지 번역 파일만)[RJ01482469] 최면 어플 NTR
번역
gyhaga
05/06 43592 143
[구매보급] [Pigtarotaro] [보이스판] 레이짱은 바람기 노출에 푹 빠진 것 같습니다 ⑤
영상
ikinokoru
05/06 31460 163
[후타주의] 클로린드 & 나비아 & 아이테르 (원신)
영상
브레머튼
05/06 16911 57
[55%] 완전자동 기계훈련 시리즈
영상
신군
05/06 24470 113
[yukimi] 이치하 5
동인
agnet666
05/06 17500 59
[구매보급/미번/촉수/이종간] 星守のレイン
미번
루파조아
05/06 13384 30
[구매보급] [버전업] RJ01548918 포스트 블러섬 -꽃이 피는 라이히와 사랑의 여제- 26.05.06 ver 1.3.0
미번
gkqisq
05/06 6972 35
구매보급) 여동생의 친구가 동경하던 G컵 갸루 코스플레이어였던 이야기
동인
GOOD
05/06 27331 177
버) RVNWaWRlb01ha2Vy 2024~2025
영상
qnpfrzlt2
05/06 31252 89
ṣ̌øłą [01~76] [96.6GB]
영상
2wjjs
05/06 28756 91
[복구] 복구 영상 4개
영상
브레머튼
05/06 19855 79
[구매보급, 미번] 하늘을 나는 하렘성의 비밀
미번
saika
05/06 8775 42
히토미펌) 19애니들 모음집
영상
yuoaijs
05/06 27157 62
이종간) 패배 강간 당하는 시리
야짤
177523
05/06 11757 24
[Misaki (Nagenyankotsu)] 제자 오나홀
동인
sgdvl
05/06 56493 423
상극의 알테르 예고 공개
정보
nyamberry
05/06 6213 19
Poriuretan 딸의 교복을 입고 외출했다가 동창에게 들킨 유부녀
동인
uzaki
05/06 22345 89
Poriuretan 비내리는 버스 정류장
동인
uzaki
05/06 12290 39
Poriuretan 유두 맞히기 게임
동인
uzaki
05/06 20821 83
(요청복구, 구버전) 서큐버스 듀얼 サキュバスデュエル
복구
werwerwer
05/06 19330 47
Poriuretan 권유
동인
uzaki
05/06 9586 35
Poriuretan 이웃집 유부녀
동인
uzaki
05/06 11310 54
Poriuretan 스트리머
동인
uzaki
05/06 10284 31