Backpack

Adjusts the layout of backpack docs to make it more laptop-friendly

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        Backpack
// @namespace   urn://https://www.georgegillams.co.uk/greasemonkey/backpack_docs
// @include     *backpack.github.io*
// @exclude     none
// @version     5
// @description:en	Adjusts the layout of backpack docs to make it more laptop-friendly
// @grant    		none
// @description Adjusts the layout of backpack docs to make it more laptop-friendly
// ==/UserScript==

let lastModifiedUrl = null;

function fixNavs() {
  const allElements = document.getElementsByTagName('NAV');
  for (let i = 0; i < allElements.length; i += 1) {
    const element = allElements[i];
    const elementClassName = `${element.className}`;
    if (elementClassName.includes('bpkdocs-sidebar-')) {
      element.style.minWidth = '10rem';
      element.style.padding = '3.75rem 2rem';
    }
  }
}

function fixImgs() {
  const allElements = document.getElementsByTagName('IMG');
  for (let i = 0; i < allElements.length; i += 1) {
    const element = allElements[i];
    const elementClassName = `${element.className}`;
    if (elementClassName.includes('bpkdocs-sections-list__heading-icon-')) {
      element.style.marginRight = '1rem';
    }
  }
}

function fixHeroImgs() {
  const allElements = document.getElementsByTagName('DIV');
  for (let i = 0; i < allElements.length; i += 1) {
    const element = allElements[i];
    const elementClassName = `${element.className}`;
    if (elementClassName.includes('bpkdocs-main-hero-image')) {
      element.style.maxHeight = '10rem';
    }
  }
}

function fixAll() {
  const currentUrl = `${window.location}`;
  if (currentUrl === lastModifiedUrl) {
    return;
  }
  fixNavs();
  fixImgs();
  fixHeroImgs();
  lastModifiedUrl = currentUrl;
}

fixAll();
setInterval(fixAll, 500);