Narrow HDBits

Help HDBits fit on narrower screens

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         Narrow HDBits
// @namespace    club.porcupine.gm_scripts.narrow_hdbits
// @version      1
// @description  Help HDBits fit on narrower screens
// @author       Sam Birch
// @license      MIT
// @icon         https://icons.duckduckgo.com/ip2/hdbits.org.ico
// @match        https://hdbits.org/*
// @grant        none
// ==/UserScript==
(function() {
    'use strict'

    let sidebar_container = document.querySelector('#sidebar-container')
    let headers = sidebar_container.querySelectorAll('TABLE > TBODY > TR > TD > H2')
    let bodies = sidebar_container.querySelectorAll('TABLE > TBODY > TR > TD > TABLE')

    sidebar_container.remove()

    let new_tr = document.createElement('TR')
    for (let i = 0; i < headers.length; i++) {
        let new_td = document.createElement('TD')
        new_td.className = 'embedded'
        new_td.append(headers[i])
        new_td.append(bodies[i])
        new_tr.append(new_td)
    }

    let new_tbody = document.createElement('TBODY')
    new_tbody.append(new_tr)

    let new_table = document.createElement('TABLE')
    new_table.className = 'main'
    new_table.append(new_tbody)

    let new_div = document.createElement('DIV')
    new_div.id = 'horizontal-sidebar-container'
    new_div.append(new_table)

    document.querySelector('.footer').before(new_div)

    const stylesheet = document.createElement('style')
    stylesheet.innerHTML = `
        #horizontal-sidebar-container { min-width: 800px; max-width: 1060px; margin: auto }
        #horizontal-sidebar-container > table { width: 100%; table-layout: fixed }
        #horizontal-sidebar-container > table > tbody > tr > td { vertical-align: top }
    `
    document.head.append(stylesheet)
}())