Ptt Add Push Floor

Add floor number to Ptt's pushes

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Ptt Add Push Floor
// @namespace    https://wiki.gslin.org/wiki/Ptt_Add_Push_Floor
// @version      0.20241121.0
// @description  Add floor number to Ptt's pushes
// @author       Gea-Suan Lin <[email protected]>
// @match        https://www.ptt.cc/bbs/*
// @match        https://www.ptt.cc/man/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    let n = 1;
    for (const el of document.getElementsByClassName('push')) {
        let floor = document.createElement('span');
        floor.setAttribute('style', 'color: gray; float: right; text-align: right; width: 2.5em;');
        floor.innerHTML = `${n}F`;
        n++;
        el.lastChild?.insertAdjacentElement('beforebegin', floor);
    }
})();