kone
소미소프트

소미소프트

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

07/28/2025, 04:59:26
유틸
2718 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.(수정추가) 미리보기 이미지 게시글 이동시에도 남아있는 오류 수정
[Liyoosa] 불법 카지노에서 정체가 탄로나 농락당하는 여주인공3p
야짤
요요코코
05/05 20260 40
[hasebe souutsu] 접대아내 숙성 6화 팔라리스의 암소편
동인
ㅇㅇ
05/05 16085 53
[hasebe souutsu] 접대아내 숙성 5화 마조 자각편
동인
ㅇㅇ
05/05 11400 39
[hasebe souutsu] 접대아내 숙성 4화 노력과 변화편
동인
ㅇㅇ
05/05 7363 33
(청아,AI,GIF) {어린이날 기념} [Red] gura,saba
영상
ArIso
05/05 20123 91
[hasebe souutsu] 접대아내 숙성 3화 밤산책편
동인
ㅇㅇ
05/05 12545 33
[hasebe souutsu] 접대아내 숙성 2화 고정 절정편
동인
ㅇㅇ
05/05 13757 37
[hasebe souutsu] 접대 아내 숙성 1화
동인
ㅇㅇ
05/05 14761 45
[기번 후 손번역] RJ01595054 이케부쿠로 섹스로이드 여학원
번역
jaaxmaster
05/05 78035 320
[한글자막] (전생슬) 슈나와 시온에게 쭉쭉~ 쥐어 짜여지는 고부타 영상
영상
실루엣21
05/05 26616 185
[구매보급]절대 굴복 오호 목소리 절정! 최강 메○가키 음마 오○코고문부터 시작
소리
이름뭐하지
05/05 9132 47
[Liyoosa] 횡령을 들켜 상사가 시키는 대로 하게 되는 경리
동인
요요코코
05/05 36562 218
지금까지 한 ntl 게임들 개인적 후기
후기 및 공략
헤비레인
05/05 16738 63
음모있음) [Gujira 4 Gou] 마구 빼달라고 하는 입원성활
동인
카오스
05/05 21731 150
[미번/번역요청]세계 이사 센터에 어서오세요 : 여자아이한테 역 헌팅 당하는게 당연한 세계 EX
동인
아돌
05/05 14902 18
아이 낳는 섬 + ai번역 두개
동인
yaoino
05/05 24722 70
청아) 페로페로☆트윈스 1.2
복구
rapbit
05/05 21631 73
청아) 작별의 체크리스트 RABPIT MOD 0.3.1 apk
rapbit
05/05 24608 45
비월선행록 이거 번역 해볼까
일반
로리망코다이스키
05/05 7169 75
(코이카츠) 버튜버 프리셋 공유
유틸
pst0025
05/05 17154 79
[버전업 알림] 음최도시 휴프노즘 1.03 적용함
번역
saika
05/05 35659 149
[보이스코믹][구매보급][한] 36
소리
책먹는망아지
05/05 21834 150
직번)[단행본][Minamida Usuke] 자지 패배 오만 사모님
동인
qlalfsla
05/05 18284 80
직번]kosuke haruhito)만끽중 5
동인
woo15
05/05 12858 69
청아, AI번역) [직번] 나와 미오의 사랑이야기 (Kagali Loka)
동인
rapbit
05/05 8818 29
AI) renbocloud 미번/번역요청 이로하 1부
동인
RMillet
05/05 13565 25
ai번역 손식질) 억압당했던 학생회 당당한 여자가 평범한 남자에게 길들여 질때까지 어머니를 인질로 원치않는 섹스로 점점 타락한다
동인
1Q2W3E4R
05/05 24212 134
Dorozumi)아양 떠는 구애 섹스
동인
woo15
05/05 22718 111
[Punpunn] 페른 NTR
동인
부히히힛
05/05 31484 165
[구매보급/버전업] RJ01527385 백작 저택의 사건부
미번
rubberduck
05/05 8020 35