Toggle InstantMarkdown width

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

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

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

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         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);
    }

})();