responsive dcinside

2025. 2. 1.

Verzia zo dňa 31.01.2025. Pozri najnovšiu verziu.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

// ==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
}