kone
소미소프트

소미소프트

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

07/28/2025, 04:59:26
유틸
2607 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.(수정추가) 미리보기 이미지 게시글 이동시에도 남아있는 오류 수정
고전 명작 도트 액션 야'겜' 3개( 쿠로바디스, 에로이코, 리지넷타)
복구
blackmalangcalf
04/28 57922 133
[구매보급/최면음성] 거짓말쟁이 후배 좋아하는 정신 지배
소리
rocoa
04/28 14393 52
[요청복구] よっぷ 서클 3종 복구
복구
rubberduck
04/28 40973 111
[AI번역] [JUNN] 네토라레바에 - 인싸 여친의 SNS 네토라레 기록 3
동인
gkcuwuwlltnnrra
04/28 28487 96
[구매보급] 【상식 개변】황국의 공주의 의식을 재기록 성 처리 봉사를 매너라고 생각해
소리
rocoa
04/28 9777 73
[미번/번역요청] 화내지마 호시카와상 3
동인
downdodo779
04/28 22448 30
[liyoosa]싫은 표정으로 성처리를 해주는 간호사
동인
요요코코
04/28 29771 177
[구매보급] [최면음성] 이키닌교
소리
rocoa
04/28 9807 34
90일) RJ01278453 Exhibitionist Observer mono Auto ko.7z
번역
ㅇㅇ
04/28 45621 106
[구매보급] [칭 호칭 15 종류】 네쵸리 손음부 ~다우너 미소녀의 간편 「비큐」시코시코 서포트♡
소리
rocoa
04/28 12187 65
[요청복구]복구 4종
복구
dmol2279
04/28 38046 69
(노모화) [miyamoto muga] 전 양아치 아내, 네토라레 당한다 2
동인
kason
04/28 19794 71
티나2 진척 12
정보
마검사리네최고
04/28 8505 36
AI/청아) 임산부 스웨터 2
야짤
날개 로봇
04/28 11546 24
양겜 기번] Whispers of the Dark Elf
번역
도로롱
04/28 34279 136
[미번역] [번역요청]착정의 섬 1.08a(완성판),AI,인외,쇼타,혐오)
미번
stmo12
04/28 14589 25
AI) 편의점에서 계산하는 무표정쨩
야짤
miso5
04/28 16574 68
[보이스코믹][구매보급][한] 마미의 덫
소리
책먹는망아지
04/28 24562 101
[noripachi] 비용을 잔뜩 버는 방법
동인
agnet666
04/28 29837 77
[기계번역] My Girlfriend Advanced to the Dancer class and she buffs everybody v1.1r 완결 (번역파일만)
번역
karuparu13
04/28 34402 129
(AI)renbocloud patreon 전체 모음 4월 최신화
야짤
RMillet
04/28 14496 53
4월 30일 횡스크롤 오네쇼타 역간겜 발매애앳!!!
정보
ballddagu
04/28 13685 36
(미번/번역요청/히토미펌)[Neko Samurai] 僕らの女神さまは…2
동인
Ghost
04/28 19428 49
[구매보급/번역요청] RJ01527385 伯爵屋敷の事件簿 -交錯する二つの思惑-
미번
rubberduck
04/28 23744 136
[P and I] 수치스러운 모델 촬영 -카메라 앞에서 드러난 거유- + After 스토리
동인
ed123
04/28 24538 61
[복구] 란스03 노모패치
유틸
imakotou
04/28 16064 28
AI, 셀레스포니아) 잠자는 아마네에게 몰래
야짤
miso5
04/28 13687 94
[구매보급 기번] RJ01319586 소악마 스마트폰 (수정중)
번역
toung
04/28 81062 267
[료나, 고문, 스캇, 청아 ... ] [ EX12 ] [미번] 게임 모음
미번
셧다운
04/28 14587 31
블아) [zmix] 그런 거나 이런 것도 내 뜻대로!
동인
agnet666
04/28 24021 55