Replace SOON and Update Views

Replaces the text "SOON" with the video duration and updates the view count in the metadata.

  1. // ==UserScript==
  2. // @name Replace SOON and Update Views
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.81
  5. // @description Replaces the text "SOON" with the video duration and updates the view count in the metadata.
  6. // @match *://www.youtube.com/*
  7. // @grant none
  8. // @license none
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function updateVideoInfo() {
  16. // Substituir "EM BREVE" pelo tempo do vídeo
  17. document.querySelectorAll('ytd-thumbnail-overlay-time-status-renderer').forEach(overlay => {
  18. const textElement = overlay.querySelector('.badge-shape-wiz__text');
  19. const spanTextElement = overlay.querySelector('#text');
  20.  
  21. if (textElement && textElement.textContent.trim() === 'EM BREVE') {
  22. const lengthElement = overlay.closest('ytd-rich-grid-media').querySelector('yt-formatted-string#length');
  23.  
  24. if (lengthElement) {
  25. const videoTime = lengthElement.textContent.trim();
  26. textElement.textContent = videoTime;
  27. if (spanTextElement) {
  28. spanTextElement.textContent = videoTime;
  29. }
  30. }
  31. }
  32. });
  33.  
  34. // Atualizar visualizações no metadado do vídeo
  35. document.querySelectorAll('ytd-video-meta-block').forEach(metaBlock => {
  36. const ariaLabel = metaBlock.querySelector('yt-formatted-string[aria-label]');
  37. const viewCountElement = metaBlock.querySelector('span.inline-metadata-item.style-scope.ytd-video-meta-block');
  38.  
  39. if (ariaLabel && viewCountElement) {
  40. // Extrai visualizações do aria-label
  41. const ariaText = ariaLabel.getAttribute('aria-label');
  42. const viewCountMatch = ariaText.match(/(\d+ visualizações)/);
  43.  
  44. if (viewCountMatch) {
  45. const viewCount = viewCountMatch[0];
  46. // Substitui o texto do metadado com a contagem de visualizações extraída
  47. viewCountElement.textContent = viewCount;
  48. }
  49. }
  50. });
  51. }
  52.  
  53. // Execute a função quando o DOM estiver totalmente carregado
  54. document.addEventListener('DOMContentLoaded', updateVideoInfo);
  55.  
  56. // Execute a função também em intervalos regulares para cobrir alterações dinâmicas
  57. setInterval(updateVideoInfo, 3000); // Executa a cada 3 segundos
  58. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址