kone
소미소프트

소미소프트

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

07/28/2025, 04:59:26
유틸
2666 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.(수정추가) 미리보기 이미지 게시글 이동시에도 남아있는 오류 수정
육상부 여자친구는 쿨하고 때때로 부끄럼
동인
hatlatal
05/01 17810 86
ai번역[Dendou Monaka] 마법 소녀 라이징 스톰 개장! 상식 개변 츠무린 랜드‼
동인
namepen44
05/01 22663 115
스위치 오프
동인
hatlatal
05/01 16331 69
[명조] 모니에 ( + 스타킹 버전 추가)
영상
브레머튼
05/01 21544 93
효과음 추가한 것 들 복구
영상
rlans
05/01 15775 83
[복구] 복구영상 1개
영상
브레머튼
05/01 16302 94
불법사이트와 차단에 대해서 ...정확하게 정리해줌
일반
lovesccubus
05/01 8415 52
[구매보급]【전편 삽입】 동경하던 선생님과 결혼했더니 SEX 완전 긍정
소리
이름뭐하지
05/01 14888 75
[촉수/세뇌/능욕] 쯔꾸르 게임 만들어 보고 있습니다. 2
창작
ㄴㄴ
05/01 9592 113
우리 함께 기다려 볼까요 5~7월 기대작 모음
정보
haeni2
05/01 18243 74
[AI번역][netorare no tami] 그녀는 노려지고 있다 속편 ~그 이후~ + 노려지고 있다 시리즈 모음
동인
hadi220
05/01 26809 63
HΔL-요루짱 파파카츠 자막 맹그러옴
영상
gombobest
05/01 17427 142
[미번,구매보급,번역요청] RJ01618876 8번 미요
미번
프리부타
05/01 23473 43
[구매보급] 개운 아게만죠 ~새해 첫판부터 긍정 갸루에게 대량 질내사정~【애니판】
소리
fm2tm
05/01 6370 43
90일, 26.05.02, 복구+번역+개선) RJ193467 소환된 이야기
번역
ㅇㅇ
05/01 33105 112
AI, 셀레스포니아) 아마네 구속 섹스
야짤
miso5
05/01 12409 91
VPN 쓰면 다 뚫린다 어쩐다 상관없고 걍 검열 자체가 존나 아니꼬움
일반
ㅏ얽초ㅏㅓㅑㅇㄹ쳐가어ㅑㅕㄹ곹ㅇ
05/01 6621 66
너스콜 경비원 올클 세이브 v1.26.4.24
세이브
ilillilllilil
05/01 15604 20
[ki-51] 아파트 이웃이 대주는 이야기 1~4
동인
agnet666
05/01 30436 58
[손번역/이미지 번역] RJ389725 큰 여자아이에게 옮겨진다! ver1.14
번역
illi11l
05/01 46328 198
[최종 정리] VPN 관련 가격, 차이, 추천, 페이백 등등 완
정보
xiondarkbullet
05/01 17002 57
띵조 모니에, 치사
영상
Poznan
05/01 13459 80
90일) RJ01072962 날개기사 세리나.7z
복구
ㅇㅇ
05/01 24331 54
[미번/번역요청]지금부터 아들의 친구와 섹스합니다
동인
아돌
05/01 16014 24
U2hhZ2d5IFN1c3Ug 영상모음
영상
karatro
05/01 24544 93
안돼! 동거라이프 DLC 식사 장면 추가
정보
라임무르
05/01 9288 32
cm9pcm9pbW1k 모음집 업데이트 알림
영상
hannanas
05/01 23953 54
아무도 안하는거 같아서 하는중
작업현황
abcdefg
05/01 14297 42
[90일][추가복구 없음] 기번자료 6종
복구
Ghost
05/01 37328 82
Poriuretan 여성 상사
동인
uzaki
05/01 19142 57