Toggle InstantMarkdown width

Adds a button to toggle between full width and GitHub default width

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Toggle InstantMarkdown width
// @description  Adds a button to toggle between full width and GitHub default width
// @match        http://localhost:8090/
// @grant        none
// @namespace    http://foo.at/
// @version      1.0
// ==/UserScript==

/*
 * Copyright 2015-2016 Stefan Weiss <[email protected]>
 * License: Public Domain
 * Please let me know if this script stops working for you.
 */

/* jshint esversion: 6 */
(function () {

    "use strict";

    if (!_qs("#js-repo-pjax-container")) {
        return;
    }

    let toggled = false;
    const btn = document.createElement("button");
    btn.textContent = "Toggle width";
    btn.style.cssText = "position: absolute; top: 10px; right: 10px";
    document.body.appendChild(btn);

    btn.onclick = function () {
        _qs(".container").style.width = toggled ? "980px" : "auto";
        _qs("#js-repo-pjax-container").style.width = toggled ? "790px" : "auto";
        _qs("article.markdown-body").style.maxWidth = toggled ? "790px" : "100%";
        toggled = !toggled;
    };

    function _qs (sel, base)
    {
        return (base || document).querySelector(sel);
    }

})();