kone
소미소프트
소미소프트

코네 사이드바 제거/ 여백 조절 확프

유틸
24,256 views · 3 points

gpt 컴퓨터 사용 기능 딸깍으로 코네 우측 사이드바 제거/ 여백 조절/ 게시물 저장 단축키 기능 있는 확프 만들었음

사이드바 제거는 디폴트 설정이고 좌우 여백은 우측 하단 슬라이더로 조절 가능해.

참고로 좌우 여백 설정은 가로 창/ 세로 창 (가로창 세로창 기준은 웹브라우저 가로 세로 사이즈 중 더 긴거 기준)개별 설정 가능하도록 되어있음.

게시물 저장 단축키는 alt+s야.

하단에 있는 코드 복사해서 확프 템퍼몽키 → 새 스크립트 만들기 → 다 지우고 아래 코드 붙여넣기 → ctrl+s 누르고 코네 돌아와서 새로고침 하면 적용됨

// UserScript

// @name Kone sub sidebar remover

// @namespace local.kone.sidebar

// @version 2.2.1

// @description 우측 패널 숨김 + 저장되는 좌우 여백 슬라이더 + Alt+S 저장/해제

// @match https://kone.gg/*

// @match https://www.kone.gg/*

// @run-at document-start

// @grant none

// @noframes

// /UserScript

(() => {

'use strict';

const HOTKEY = { code: 'KeyS', alt: true, ctrl: false, shift: false, meta: false };

const HOTKEY_TEXT = 'Alt+S';

const STYLE_ID = 'kone-helper-style-v2';

const TOAST_ID = 'kone-helper-notice';

if (document.getElementById(STYLE_ID)) return;

const SIDEBAR = '#main div.hidden.w-64.shrink-0[class~="lg:block"]:has(> div.sticky.top-16)';

const PANEL_ID = 'kone-margin-controls';

const STORAGE_KEY = 'kone-helper-margins-v1';

const orientation = window.matchMedia('(min-aspect-ratio: 1/1)');

const profile = () => orientation.matches ? 'landscape' : 'portrait';

const clampMargin = value => typeof value === 'number' && Number.isFinite(value)

? Math.max(0, Math.min(30, Math.round(value))) : 0;

function readMargins() {

try {

const saved = JSON.parse(localStorage.getItem(STORAGE_KEY)) || {};

return { landscape: clampMargin(saved.landscape), portrait: clampMargin(saved.portrait) };

} catch {

return { landscape: 0, portrait: 0 };

}

}

let margins = readMargins();

let slider, valueLabel, panelDetails;

let storageWarningShown = false;

function applyMargin() {

const value = margins[profile()];

document.documentElement?.style.setProperty('--kone-side-margin', ${value}%, 'important');

if (slider) {

slider.value = String(value);

slider.setAttribute('aria-valuetext', 양쪽 각각 ${value}%);

valueLabel.textContent = ${orientation.matches ? '가로 창' : '세로 창'} · 양쪽 각각 ${value}%;

}

}

function saveMargin(value) {

// 다른 탭에서 변경한 반대 방향 설정도 보존합니다.

const next = readMargins();

next[profile()] = clampMargin(value);

margins = next;

applyMargin();

try {

localStorage.setItem(STORAGE_KEY, JSON.stringify(margins));

} catch {

if (!storageWarningShown) {

notice('설정을 저장할 수 없습니다. 사이트 저장 공간 허용 여부를 확인해 주세요.');

storageWarningShown = true;

}

}

}

orientation.addEventListener('change', applyMargin);

window.addEventListener('storage', event => {

if (event.key !== STORAGE_KEY && event.key !== null) return;

margins = readMargins();

applyMargin();

});

const style = document.createElement('style');

style.id = STYLE_ID;

style.textContent = `

${SIDEBAR} { display: none !important; }

/* 0%는 v2.1의 최대 너비. 좌우 각각 설정 비율만큼 줄입니다. */

#main .max-w-7xl:has(#post-article) {

width: calc(100% - var(--kone-side-margin, 0%) - var(--kone-side-margin, 0%)) !important;

margin-inline: auto !important;

max-width: none !important;

min-width: 0 !important;

}

#main div.flex.gap-4:has(> div.hidden.w-64.shrink-0[class~="lg:block"] > div.sticky.top-16):has(#post-article) {

padding-right: 0 !important;

}

#post-article,

#post-article .article-prose,

#post-article .article-prose > .tiptap {

width: 100% !important;

max-width: none !important;

min-width: 0 !important;

}

/* 접기 영역 등 이미지가 들어 있는 최상위 블록의 40rem 제한 해제.

이미지 자체뿐 아니라 이를 감싼 본문 블록도 가용 너비를 사용합니다.

접힘 상태, 내부 다단 배치, 스티커 전용 블록은 그대로 둡니다. */

#post-article .article-prose .tiptap > :has(.image-view-wrapper) {

max-width: none !important;

min-width: 0 !important;

}

/* 실제 첨부 이미지와 그 컨테이너를 함께 확장 */

#post-article .article-prose .image-view-wrapper,

#post-article .article-prose .image-view-wrapper > .relative,

#post-article .article-prose .image-view-wrapper > .relative > button:has(> img) {

width: 100% !important;

max-width: 100% !important;

min-width: 0 !important;

}

#post-article .article-prose .image-view-wrapper img {

display: block !important;

width: 100% !important;

max-width: 100% !important;

height: auto !important;

max-height: none !important;

aspect-ratio: auto !important;

object-fit: contain !important;

}

#${PANEL_ID} {

position: fixed !important; right: 16px !important; bottom: 16px !important;

z-index: 2147483646 !important; max-width: calc(100vw - 32px) !important;

}

body:not(:has(#post-article)) #${PANEL_ID} { display: none !important; }

#${TOAST_ID} {

position: fixed !important; right: 20px !important; bottom: 190px !important;

z-index: 2147483647 !important; max-width: min(420px, 85vw) !important;

padding: 12px 16px !important; border-radius: 10px !important;

background: #202124 !important; color: #fff !important;

font: 14px/1.5 system-ui, sans-serif !important;

box-shadow: 0 4px 18px #0004 !important; pointer-events: none !important;

}

`;

let noticeTimer;

function notice(message) {

if (!document.body) return;

let box = document.getElementById(TOAST_ID);

if (!box) {

box = document.createElement('div');

box.id = TOAST_ID;

box.setAttribute('role', 'status');

box.setAttribute('aria-live', 'polite');

document.body.appendChild(box);

}

box.textContent = message;

clearTimeout(noticeTimer);

noticeTimer = setTimeout(() => box.remove(), 3500);

}

function mountStyle() {

applyMargin();

(document.head || document.documentElement).appendChild(style);

}

function mountControls() {

if (!document.body || document.getElementById(PANEL_ID)) return;

const host = document.createElement('div');

host.id = PANEL_ID;

const shadow = host.attachShadow({ mode: 'open' });

shadow.innerHTML = `

<style>

:host { all: initial; color-scheme: dark; font: 13px/1.5 system-ui, sans-serif; color: #fff; }

* { box-sizing: border-box; }

details { width: 280px; max-width: calc(100vw - 32px); border: 1px solid #555;

border-radius: 12px; background: #202124; box-shadow: 0 4px 18px #0004; }

details:not([open]) { width: auto; }

summary { padding: 9px 13px; cursor: pointer; user-select: none; }

.settings { padding: 0 14px 14px; }

label { display: block; margin-bottom: 8px; }

input { display: block; width: 100%; margin: 0; accent-color: #a7c7ff; cursor: pointer; }

.ends { display: flex; justify-content: space-between; font-size: 11px; color: #ccc; margin-top: 5px; }

p { margin: 10px 0; color: #ccc; font-size: 12px; }

button { font: inherit; color: #fff; background: #383b40; border: 1px solid #666;

border-radius: 6px; padding: 4px 9px; cursor: pointer; }

summary:focus-visible, input:focus-visible, button:focus-visible { outline: 2px solid #a7c7ff; outline-offset: 3px; }

</style>

<details>

<summary>좌우 여백</summary>

<div class="settings">

<label for="margin"><output id="value" for="margin"></output></label>

<input id="margin" type="range" min="0" max="30" step="1" value="0" aria-label="좌우 여백, 양쪽 각각" />

<div class="ends"><span>0% · 최대 너비</span><span>30% · 좁게</span></div>

<p>가로 창·세로 창 설정이 각각 자동 저장됩니다.</p>

<button type="button">최대 너비로 복원</button>

</div>

</details>`;

slider = shadow.querySelector('input');

valueLabel = shadow.querySelector('output');

panelDetails = shadow.querySelector('details');

slider.addEventListener('input', () => saveMargin(Number(slider.value)));

shadow.querySelector('button').addEventListener('click', () => saveMargin(0));

shadow.addEventListener('keydown', event => {

if (event.key === 'Escape') {

panelDetails.open = false;

shadow.querySelector('summary').focus();

}

});

document.body.appendChild(host);

applyMargin();

}

if (document.documentElement) mountStyle();

else {

const rootObserver = new MutationObserver(() => {

if (!document.documentElement) return;

rootObserver.disconnect();

mountStyle();

});

rootObserver.observe(document, { childList: true });

}

function isTyping(event) {

return event.composedPath().some(node => node instanceof HTMLElement && (

node.isContentEditable || node.matches('input, textarea, select, [role="textbox"], [role="combobox"]')

));

}

function findSaveButton() {

const article = document.getElementById('post-article');

if (!article) return null;

const candidates = [...article.querySelectorAll('button')].filter(button => {

if (button.closest('#post-comment, #post-list')) return false;

const icon = button.querySelector('svg.lucide-bookmark, svg.lucide-bookmark-check, svg.lucide-bookmark-minus');

const label = button.getAttribute('aria-label') || '';

const isSave = Boolean(icon) || /^(save|unsave|saved|remove from saved|저장|저장 취소|저장 해제|저장됨|북마크|북마크 해제)$/i.test(label.trim());

return isSave && button.getClientRects().length > 0 && getComputedStyle(button).visibility !== 'hidden';

});

return candidates.length === 1 ? candidates[0] : null;

}

let lastActivation = -Infinity;

document.addEventListener('keydown', event => {

if (event.code !== HOTKEY.code || event.altKey !== HOTKEY.alt ||

event.ctrlKey !== HOTKEY.ctrl || event.shiftKey !== HOTKEY.shift ||

event.metaKey !== HOTKEY.meta || event.isComposing || isTyping(event)) return;

if (!document.getElementById('post-article')) return;

if (document.querySelector('[role="dialog"][data-state="open"], [role="alertdialog"], dialog[open]')) return;

event.preventDefault();

event.stopImmediatePropagation();

if (event.repeat || performance.now() - lastActivation < 800) return;

const button = findSaveButton();

if (!button) {

notice('게시물 저장 버튼을 찾지 못했습니다. 페이지를 새로고침해 주세요.');

return;

}

if (button.disabled || button.getAttribute('aria-disabled') === 'true' || button.getAttribute('aria-busy') === 'true') {

notice('현재 저장 버튼을 사용할 수 없습니다.');

return;

}

lastActivation = performance.now();

button.click();

notice('저장 버튼을 눌렀습니다. 저장 상태는 사이트에서 확인해 주세요.');

}, true);

const ready = () => {

mountControls();

notice(Kone 도우미 실행됨 · 우측 하단에서 좌우 여백 조절 · 저장/해제 ${HOTKEY_TEXT});

};

if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', ready, { once: true });

else ready();

})();

3
1 comment
유효하지않다고 나오는대...
All
Title
Body