썸네일 크기조절 스크립트
챗지피티로 만들었는데 오류 생길수있음 문제시 글삭
1
ㄴ 기존 썸네일 크기
1
ㄴ 스크립트 작동 후 썸네일 크기
1
ㄴ 썸네일 너비 설정 클릭
1
너비 숫자만 쓰고 (뒤에 px는 자동으로 써짐) 확인 누르면
1
높이는 대충 4:3 비율로 계산되고 다시 확인 누르기 >> 새로고침
초기 기본 너비 : 500
초기 기본 높이 : 375
아래는 스크립트입니다
// ==UserScript==
// @name kone.gg 썸네일 크기 조절 (너비만 입력)
// @namespace http://tampermonkey.net/
// @version 1.3
// @description kone.gg 미리보기 썸네일 크기를 너비만 입력해 간편하게 조절합니다.
// @match https://kone.gg/*
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
(function () {
'use strict';
const defaultWidth = '500px';
const defaultHeight = '375px'; // 초기 기본 높이, 계산용 참고
const width = GM_getValue('thumbnailWidth', defaultWidth);
const height = GM_getValue('thumbnailHeight', defaultHeight);
function normalizeSize(input) {
if (!input) return null;
input = input.trim();
if (/^\d+$/.test(input)) {
return input + 'px';
}
return input; // 이미 단위 포함되어 있는 경우
}
function extractPixels(value) {
const match = /^(\d+)(px)?$/.exec(value.trim());
return match ? parseInt(match[1], 10) : null;
}
function updateThumbnailSize() {
const newWidthRaw = prompt('썸네일 너비를 입력하세요 (예: 500 또는 100%)', width);
const newWidth = normalizeSize(newWidthRaw);
if (!newWidth) return;
let newHeight;
// 비율 계산 (숫자일 경우에만 적용)
const widthNum = extractPixels(newWidth);
if (widthNum !== null) {
const heightNum = Math.round(widthNum * 0.75); // 4:3 비율
newHeight = heightNum + 'px';
} else {
newHeight = 'auto'; // 퍼센트나 auto 같은 경우
}
GM_setValue('thumbnailWidth', newWidth);
GM_setValue('thumbnailHeight', newHeight);
alert(`썸네일 크기 변경:\n너비: ${newWidth}\n높이: ${newHeight}\n\n페이지를 새로고침하면 적용됩니다.`);
}
function applyThumbnailStyle(w, h) {
const style = document.createElement('style');
style.id = 'custom-thumbnail-style';
style.textContent = `
img.max-w-50.max-h-40 {
max-width: ${w} !important;
max-height: ${h} !important;
}
`;
document.head.appendChild(style);
}
GM_registerMenuCommand('썸네일 너비 설정 (높이는 자동 계산)', updateThumbnailSize);
applyThumbnailStyle(width, height);
})();
4
2 comments
opooo
06/01/25 너비아니
cloud67p
06/15/25 참 좋은데 맨 아래쪽 게시글 한두개는 100%기준 아래가 짤리네요
공지
AI 이미지 관련 공지 및 관련 규정 수정 공지
1uF
05/02
62053
22
AI 이미지 관련 공지 및 관련 규정 수정 공지
공지
1uF
05/02 62053 22
공지
‼️뉴비 필독 가이드‼️
1uF
05/02
92865
134
‼️뉴비 필독 가이드‼️
공지
1uF
05/02 92865 134
공지
🔔[필독] 채널 규정 & 신문고 (2026 04 05~)
SK
04/05
206755
-25
🔔[필독] 채널 규정 & 신문고 (2026 04 05~)
공지
SK
04/05 206755 -25
공지
🔔[필독] 탭 별 이용 가이드 (20260206~)
Etrick
02/05
255075
-41
🔔[필독] 탭 별 이용 가이드 (20260206~)
공지
Etrick
02/05 255075 -41
공지
[필독] 서브에 자주 올라오는 여러 가지 질문 모음 (20251026~)
SK
05/17/25
1244551
-14
[필독] 서브에 자주 올라오는 여러 가지 질문 모음 (20251026~)
공지
SK
05/17/25 1244551 -14
s/somisoft
• 143,985 subscribers여러가지 다루는 서브
Created 05/17/2025, 14:58:43