responsive dcinside

2025. 2. 1.

Stan na 31-01-2025. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        responsive dcinside
// @namespace   Violentmonkey Scripts
// @match       https://gall.dcinside.com/*
// @grant       none
// @version     2.1
// @author      -
// @license     MIT
// @description 2025. 2. 1.
// ==/UserScript==

// adjust left margin (responsive)
try{
  document.getElementById('top').style.margin = '0 -145px'
  document.getElementsByClassName('wrap_inner')[0].style.width = '1160px'
} catch (e) {
  console.error(e);
}


// adjust layout
var prev = 1920;

window.onload = function() {
  onResize(window.innerWidth);
};

window.onresize = function() {
  onResize(window.innerWidth);
};

function onResize(w) {
  if (w < 1200 && prev >= 1200){
    try{
      // 1160 layout to 840 layout
      // header
      document.getElementsByClassName('dchead')[0].style.width = '840px'
      document.getElementsByClassName('dchead')[0].style.paddingRight = '320px'
      document.getElementsByClassName('area_links')[0].style.paddingRight = '320px'
      document.getElementsByClassName('gnb')[0].style.width = '840px'
      document.getElementsByClassName('gnb')[0].style.paddingRight = '320px'
      document.getElementsByClassName('gnb_list')[0].style.width = '520px'

      document.getElementById('search_wrap').style.left = '100%'
      document.getElementById('search_wrap').style.marginLeft = '-684px'
      document.getElementsByClassName('visit_bookmark')[0].style.width = '840px'
      document.getElementsByClassName('visit_bookmark')[0].style.paddingRight = '320px'

      // content
      document.getElementsByClassName('right_content')[0].style.marginTop = '-40px'
    } catch (e) {
      console.error(e)
    }
  }
  if (w >= 1200 && prev < 1200) {
    try{
      // original 1160 layout
      // header
      document.getElementsByClassName('dchead')[0].style.width = '1160px'
      document.getElementsByClassName('dchead')[0].style.paddingRight = '0'
      document.getElementsByClassName('area_links')[0].style.paddingRight = '0'
      document.getElementsByClassName('gnb')[0].style.width = '1160px'
      document.getElementsByClassName('gnb')[0].style.paddingRight = '0'
      document.getElementsByClassName('gnb_list')[0].style.width = '840px'

      document.getElementById('search_wrap').style.left = '50%'
      document.getElementById('search_wrap').style.marginLeft = '-182px'
      document.getElementsByClassName('visit_bookmark')[0].style.width = '1160px'
      document.getElementsByClassName('visit_bookmark')[0].style.paddingRight = '0'

      // content
      document.getElementsByClassName('right_content')[0].style.marginTop = '0'
    } catch (e) {
      console.error(e)
    }
  }

  prev = w
}