Ptt Add Push Floor

Add floor number to Ptt's pushes

  1. // ==UserScript==
  2. // @name Ptt Add Push Floor
  3. // @namespace https://wiki.gslin.org/wiki/Ptt_Add_Push_Floor
  4. // @version 0.20241121.0
  5. // @description Add floor number to Ptt's pushes
  6. // @author Gea-Suan Lin <darkkiller@gmail.com>
  7. // @match https://www.ptt.cc/bbs/*
  8. // @match https://www.ptt.cc/man/*
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. let n = 1;
  17. for (const el of document.getElementsByClassName('push')) {
  18. let floor = document.createElement('span');
  19. floor.setAttribute('style', 'color: gray; float: right; text-align: right; width: 2.5em;');
  20. floor.innerHTML = `${n}F`;
  21. n++;
  22. el.lastChild?.insertAdjacentElement('beforebegin', floor);
  23. }
  24. })();