kone
소미소프트

소미소프트

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

07/28/2025, 04:59:26
유틸
2510 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.(수정추가) 미리보기 이미지 게시글 이동시에도 남아있는 오류 수정
Kiosk 암호 자동 입력기 2.0
유틸
oroshinashi9
03/26 5260 32
[의상 파일 공유][비밀 노출 -배덕의 달콤함에 물든 마나카-] 데빌
유틸
akuma
03/26 12111 19
[요청복구] Prison Hero 감옥용사 조이플 구동패치
유틸
감비아
03/22 2784 3
Tsukuru Extractor에서 추출한 .txt 파일 재미나이2.5 flash로 번역하는 파이썬 코드
유틸
lovesccubus
03/21 2858 3
mp3,wav 여러 파일 한개로 병합해주는 프로그램 만듬
유틸
noname
03/21 11706 20
fapcraft (제니모드) v1.1
유틸
monolithliza
03/20 10233 48
하츠네 미쿠 (코이카츠) 프리셋 공유 v2
유틸
pst0025
03/19 19994 36
키오스크 비번 자동입력기(업그레이드)
유틸
oroshinashi9
03/19 6149 13
(코이카츠) 셀레스포니아 캐릭터 공유 (우리가 아는 그 게임 맞음)
유틸
pst0025
03/18 19744 38
(코이카츠) Vrchat 캐릭터 공유
유틸
pst0025
03/17 10851 42
트랜스크랩 1.0.5 패치에서 오류나는 사람들은 이거 다운받으셈.
유틸
liberty
03/17 13832 25
악!! 저는 파일 올릴 때 최신화 체크도 안하는 병신입니다!!
유틸
pst0025
03/16 6902 28
블아 캐릭터 공유 빠진거 3개
유틸
pst0025
03/16 10578 38
(코이카츠) 벽람 캐릭터 공유 [이것도 많다....]
유틸
pst0025
03/16 11931 43
(코이카츠) 블아 캐릭터 공유 [아무튼 ㅈㄴ 많음]
유틸
pst0025
03/16 13178 75
(코이카츠) 명조 캐릭터 공유
유틸
pst0025
03/16 19590 54
(코이카츠) '데어라' 프리셋 공유
유틸
pst0025
03/16 9461 45
던전 앤 브라이드 치트모드 1.56업데이트 + 번역모드 대응버전 출시 *04/04 18:31 수정
유틸
rengester
03/13 17796 37
아이폰) 아이폰 렌파이 자동 번역기 1티어 나옴
유틸
quilqiil132
03/12 4984 6
유니티 플러그인 만들어옴(받침유무에 따른 조사 수정)
유틸
neighborsbear
03/11 5628 14
아이폰 필독)아이폰용 무료 렌파이 자동 번역기앱 나옴
유틸
quilqiil132
03/10 5685 5
JSON AI 번역기 (마나카 커스텀미션 및 etc..)
유틸
bunta_expert
03/10 6625 20
MV 백로그 플러그인) Lunatlazur_BackLog.js
유틸
ㅇㅇ
03/09 7464 5
아리아 서큐즘 노모 텍스쳐 대체 방식
유틸
paleblood
03/09 7050 13
[노모패치] 324709 노엘 간바리마스! v.1.2.2
유틸
dd
03/07 13169 33
Darkest Dungeon NSFW 십덕 스킨모드
유틸
hibeast
03/07 13808 14
▼ 素材(Materials) ## VX Ace to MV Converter.rb
유틸
ㅇㅇ
03/06 10286 4
야식메뉴판 Plus 업뎃 안내 - 1.2.1
유틸
qqoro
03/06 16493 38
여동생 생활 판타지 DLC 2.0.1 치트에디터(파이썬)
유틸
jghkk9
03/05 5146 7
코이카츠 프리셋 공유
유틸
wonder11
03/04 9865 34