2ch-thread-list

thread list instead of board list for 2ch

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         2ch-thread-list
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  thread list instead of board list for 2ch
// @author       anonimuslegion
// @match        https://2ch.hk/*/res/*.html
// @match        http://2ch.hk/*/res/*.html
// @icon         https://www.google.com/s2/favicons?sz=64&domain=2ch.hk
// @grant        none
// @license      GNU GPL
// ==/UserScript==
let currentBoard = window.location.pathname.split('/')[1];

function getThreadsList(board, numOfThreads) {
    var threadsList = []
    $.getJSON(`https://2ch.hk/${currentBoard}/catalog.json`, function(data) {
        for (const [key, value] of Object.entries(data.threads)) {
            threadsList.push([value['subject'], value['num'], value['posts_count'], value['files'][0]['thumbnail'], value['comment']])
        }
        generateThreadsCards(threadsList, numOfThreads)
    })
}

function generateThreadsCards(thList, numOfCards) {
    $('#fmenu').empty()
    $('#fmenu').append(`<li class="fm__item">
                          <div class="fm__header" data-header="other">Треды /${currentBoard}/</div>
                          <ul class="fm__sub" id="fm__other" style="padding-left:0px;">
                          </ul>
                        </li>`)
    for (const element of thList.slice(0, numOfCards)) {
        $("#fm__other").append(`
        <li>
          <div class="thread_card" style=" background-color:var(--theme_default_postbg); padding:4px; margin:5px 0px 5px 0px;height:100px;border-radius:3px">
            <div class="thread_card_header" style="display: flex; justify-content: space-between; padding-bottom:3px">
              <a href="/${currentBoard}/res/${element[1]}.html" style="margin:0px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><b>${element[0]}</b></a>
            </div>
            <img src="${element[3]}" style="float:left; object-fit: cover; width: 70px; height: 70px; border-radius: 4px;vertical-align: top;">
            <span style="word-wrap: break-word; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
            text-overflow: ellipsis;padding-left:4px;">${element[4].replace(/<(?!(br|span|strong|a|p)[ >])[a-zA-Z][^>]*>.*?<\/[^>]*>/g,'')}</span>
          </div>
        </li>
        `)
    }
}

$('.cntnt__aside').css('max-width', '18%')
getThreadsList(currentBoard, 50);