Move Tag Posts Count

Moves the tag's posts count after the tag name on a webpage with specific elements.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Move Tag Posts Count
// @version      1.6
// @description  Moves the tag's posts count after the tag name on a webpage with specific elements.
// @match      https://chan.sankakucomplex.com/post*
// @match      https://chan.sankakucomplex.com/*/post*
// @match      https://chan.sankakucomplex.com/*/post/*
// @match      https://chan.sankakucomplex.com/?*tags*
// @grant        none
// @license      MIT
// @namespace https://greasyfork.org/users/1104432

// ==/UserScript==

(function() {
    'use strict';

    document.querySelectorAll('div[id^="tag_container"]').forEach(div => {
        const span = document.createElement('span')

        span.style.color = 'grey'
        span.innerHTML = ' ' + transformNumber(div.querySelector('.tooltip').innerHTML.match(/Posts: <span data-count="(\d*)">/i)[1])
        div.insertBefore(span, div.querySelector('a').nextSibling)
    });

    function transformNumber(numberString) {

        const numberParts = numberString.trim().split(/(\d+\.?\d*)([KMB])?/);
        let number = parseFloat(numberParts[1]);
        const suffix = numberParts[2];

        if (suffix === 'K') {
            number *= 1000;
        } else if (suffix === 'M') {
            number *= 1000000;
        }

        return number.toLocaleString("ro-RO", {
            useGrouping: true
        });
    }
})();