Bitcoin Forum

Other => Meta => Topic started by: 0x256 on March 08, 2024, 08:09:33 PM



Title: [script] Show number (new replies to your posts)
Post by: 0x256 on March 08, 2024, 08:09:33 PM
https://i.ibb.co/CsqrSJb/image.png (https://ibb.co/JFNhSxv)
The initial code needs to be developed and modified
Code:
// ==UserScript==
// @name         show new replies len
// @namespace    https://bitcointalk.org/
// @version      0.1
// @description  Show number (new replies to your posts)
// @author       0x256
// @include      https://bitcointalk.org/*
// @grant        GM_addStyle

// ==/UserScript==

(function() {
'use strict';
GM_addStyle("#new_replies_len{color: white;background-color: red;padding: 1px 5px;border-radius: 5px;cursor: pointer;}");

window.addEventListener("load", (event) => {
  let hellomember = document.getElementById("hellomember");
  hellomember.insertAdjacentHTML('beforebegin', `<a style="text-decoration: none" href="https://bitcointalk.org/index.php?action=unreadreplies"><span id="new_replies_len"></span></a>`);

  var xhttp2 = new XMLHttpRequest();
  xhttp2.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      var doc2 = new DOMParser().parseFromString(this.responseText, 'text/html');
      var replies_len = doc2.querySelectorAll("table.bordercolor > tbody > tr > td > table.bordercolor > tbody > tr").length -1;

      var modal2 = document.getElementById("new_replies_len");
      modal2.innerHTML = replies_len;
    }
  };
  xhttp2.open("GET", "https://bitcointalk.org/index.php?action=unreadreplies", true);
  xhttp2.send();
});


})();

if you want custom bitcointalk css header click here (https://bitcointalk.org/index.php?topic=5240105)


Title: Re: [script] Show number (new replies to your posts)
Post by: Elissa~sH on March 09, 2024, 03:17:20 PM
I got a nice look when you posted your main code in 2020. But today, in the year 2024, the number has changed. It's great to see the numbers in the reply post.