YouTube.com - channel name and upload date in tab title, no notification count

The interaction reminder (notification count) is annoying and serves no purpose. I know there are notifications. There are always notifications. Also, to be useful, add the channel name at the start of the tab title and upload date at the end. 9/4/2022, 10:40:56 AM

  1. // ==UserScript==
  2. // @name YouTube.com - channel name and upload date in tab title, no notification count
  3. // @namespace Violentmonkey Scripts
  4. // @match https://www.youtube.com/watch
  5. // @grant none
  6. // @version 1.0
  7. // @author -
  8. // @description The interaction reminder (notification count) is annoying and serves no purpose. I know there are notifications. There are always notifications. Also, to be useful, add the channel name at the start of the tab title and upload date at the end. 9/4/2022, 10:40:56 AM
  9. // ==/UserScript==
  10.  
  11.  
  12. const prepareTitle = function (originalTitle, channelPrefix, dateSuffix) {
  13. return channelPrefix + originalTitle + dateSuffix;
  14. }
  15.  
  16. const getDateSuffix = function () {
  17. var dateSuffix = "";
  18. const dateElement = document.querySelector("div#info-strings yt-formatted-string.ytd-video-primary-info-renderer");
  19. if(dateElement !== null) {
  20. const date = dateElement.innerText.trim();
  21. var htmlElement = document.querySelector("html");
  22. if((htmlElement !== null) && (htmlElement.attributes.hasOwnProperty("lang"))) {
  23. if(htmlElement.attributes["lang"].value == "en-GB") {
  24. const dateParts = date.split(" ");
  25. if(dateParts.length == 3) {
  26. const day = dateParts[0];
  27. const monthText = dateParts[1];
  28. const year = dateParts[2];
  29. var month = null;
  30. switch (monthText) {
  31. case "Jan":
  32. month = 1; break;
  33. case "Feb":
  34. month = 2; break;
  35. case "Mar":
  36. month = 3; break;
  37. case "Apr":
  38. month = 4; break;
  39. case "May":
  40. month = 5; break;
  41. case "Jun":
  42. month = 6; break;
  43. case "Jul":
  44. month = 7; break;
  45. case "Aug":
  46. month = 8; break;
  47. case "Sept":
  48. month = 9; break; // seriously, fuck YouTube for doing "Sept" and not "Sep"
  49. case "Oct":
  50. month = 10; break;
  51. case "Nov":
  52. month = 11; break;
  53. case "Dec":
  54. month = 12; break;
  55. default:
  56. month = null;
  57. }
  58. if (month !== null) {
  59. dateSuffix = " - " + year + "-" + month.toString().padStart(2, "0") + "-" + day.padStart(2, "0");
  60. }
  61. }
  62. }
  63. }
  64. } // end if(dateElement !== null)
  65. return dateSuffix;
  66. }
  67.  
  68. setInterval(function() {
  69. const originalTitle = window.title.toString().trim();
  70. const channelNameElement = document.querySelector("ytd-channel-name#channel-name.style-scope.ytd-video-owner-renderer div#container.style-scope.ytd-channel-name div#text-container.style-scope.ytd-channel-name yt-formatted-string#text.style-scope.ytd-channel-name a.yt-simple-endpoint.style-scope.yt-formatted-string");
  71. var channelPrefix = ""; // if there's no channel name currently available, don't prefix with anything
  72. if((channelNameElement !== null) && (channelNameElement.innerText.trim() != "")) {
  73. var channelPrefix = channelNameElement.innerText.trim() + ": ";
  74. }
  75. var titleElement = document.querySelector("title");
  76. const objectDebugString = "[object"; // sometimes, window.title will be [object HTMLElementDiv] for some idiotic reason, and that will be the stringified version of it! Fucking hell!
  77. if((titleElement !== null) && (! originalTitle.startsWith(objectDebugString))) {
  78. var currentTitle = titleElement.innerText;
  79. const dateSuffix = getDateSuffix();
  80. var newTitle = prepareTitle(originalTitle, channelPrefix, dateSuffix);
  81. if (currentTitle != newTitle) {
  82. titleElement.innerText = newTitle;
  83. }
  84. }
  85. }, 500)