Move Tag Posts Count

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

  1. // ==UserScript==
  2. // @name Move Tag Posts Count
  3. // @version 1.6
  4. // @description Moves the tag's posts count after the tag name on a webpage with specific elements.
  5. // @match https://chan.sankakucomplex.com/post*
  6. // @match https://chan.sankakucomplex.com/*/post*
  7. // @match https://chan.sankakucomplex.com/*/post/*
  8. // @match https://chan.sankakucomplex.com/?*tags*
  9. // @grant none
  10. // @license MIT
  11. // @namespace https://greasyfork.org/users/1104432
  12.  
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. document.querySelectorAll('div[id^="tag_container"]').forEach(div => {
  19. const span = document.createElement('span')
  20.  
  21. span.style.color = 'grey'
  22. span.innerHTML = ' ' + transformNumber(div.querySelector('.tooltip').innerHTML.match(/Posts: <span data-count="(\d*)">/i)[1])
  23. div.insertBefore(span, div.querySelector('a').nextSibling)
  24. });
  25.  
  26. function transformNumber(numberString) {
  27.  
  28. const numberParts = numberString.trim().split(/(\d+\.?\d*)([KMB])?/);
  29. let number = parseFloat(numberParts[1]);
  30. const suffix = numberParts[2];
  31.  
  32. if (suffix === 'K') {
  33. number *= 1000;
  34. } else if (suffix === 'M') {
  35. number *= 1000000;
  36. }
  37.  
  38. return number.toLocaleString("ro-RO", {
  39. useGrouping: true
  40. });
  41. }
  42. })();