YouTube Show Buffer Speed

Show Buffer Speed on Youtube

  1. // ==UserScript==
  2. // @name YouTube Show Buffer Speed
  3. // @editor Raphahxb (xbox)
  4. // @description Show Buffer Speed on Youtube
  5. // @version 1.0
  6. // @include htt*://*.youtube.com/*
  7. // @grant none
  8. // @match http://*.youtube.com/*
  9. // @match https://*.youtube.com/*
  10. // @encoding UTF-8
  11. // @namespace https://gf.qytechs.cn/users/7000
  12. // ==/UserScript==
  13.  
  14.  
  15. function bytesToSize(bytes, precision)
  16. {
  17. var kilobyte = 1024;
  18. var megabyte = kilobyte * 1024;
  19. var gigabyte = megabyte * 1024;
  20. var terabyte = gigabyte * 1024;
  21. if ((bytes >= 0) && (bytes < kilobyte)) {
  22. return bytes + ' B';
  23. } else if ((bytes >= kilobyte) && (bytes < megabyte)) {
  24. return (bytes / kilobyte).toFixed(precision) + ' KB';
  25. } else if ((bytes >= megabyte) && (bytes < gigabyte)) {
  26. return (bytes / megabyte).toFixed(precision) + ' MB';
  27. } else if ((bytes >= gigabyte) && (bytes < terabyte)) {
  28. return (bytes / gigabyte).toFixed(precision) + ' GB';
  29. } else if (bytes >= terabyte) {
  30. return (bytes / terabyte).toFixed(precision) + ' TB';
  31. } else {
  32. return bytes + ' B';
  33. }
  34. }
  35. var d=1;
  36. var lastbytes=0;
  37. var loadedbytes=0;
  38. var totalbytes=0;
  39. var startedbytes=0;
  40. function bytesloaded() {
  41. if(elem = document.getElementById('movie_player')) {
  42. if (typeof elem.getVideoBytesTotal == 'function') {
  43. //if (elem.getVideoBytesTotal()) {
  44. totalbytes = elem.getVideoBytesTotal();
  45. loadedbytes = elem.getVideoBytesLoaded();
  46. startedbytes = elem.getVideoStartBytes();
  47. //if (loadedbytes > 0) {
  48. //alert(d);
  49. if (d < 4) {
  50. /*
  51. var now = elem.getVideoBytesLoaded();
  52. var tot = (now-lastbytes2)*4;
  53. lastbytes2 = now;
  54. document.getElementById('bufferspeed').innerHTML = bytesToSize(tot) + "/s";
  55. */
  56.  
  57. if (document.getElementById('bytesload')) {
  58. document.getElementById('startedbytes').innerHTML = bytesToSize(startedbytes);
  59. document.getElementById('bytesload').innerHTML = bytesToSize(loadedbytes);
  60. document.getElementById('bytestotal').innerHTML = bytesToSize(totalbytes);
  61. d++;
  62. }
  63. else {
  64. document.getElementById('watch-headline-title').innerHTML += '<BR><span style="font-size:10px;" id="bufferspeed"></span>&nbsp;&nbsp;&nbsp;<span style="font-size:10px;" id="bytesload"></span><span style="font-size:10px;">/</span><span style="font-size:10px;" id="bytestotal"> </span>&nbsp;&nbsp;&nbsp;<span style="font-size:10px;" id="startedbytes"> </span>';
  65. document.getElementById('bytesload').innerHTML = bytesToSize(loadedbytes);
  66. document.getElementById('bytestotal').innerHTML = bytesToSize(totalbytes);
  67. document.getElementById('startedbytes').innerHTML = bytesToSize(startedbytes);
  68. }
  69. }
  70. else if (d == 4) {
  71. var now = elem.getVideoBytesLoaded();
  72. var tot = (now-lastbytes)/4;
  73. lastbytes = now;
  74. document.getElementById('bufferspeed').innerHTML = bytesToSize(tot) + "/s";
  75. document.getElementById('bytesload').innerHTML = bytesToSize(loadedbytes);
  76. document.getElementById('bytestotal').innerHTML = bytesToSize(totalbytes);
  77. document.getElementById('startedbytes').innerHTML = bytesToSize(startedbytes);
  78. d=1;
  79. }
  80. //}
  81. //alert(bytesToSize(loadedbytes) + "/" + bytesToSize(totalbytes));""
  82. //}
  83. }
  84. }
  85. setTimeout(function () {
  86. bytesloaded();
  87. }, 1000);
  88. }
  89. bytesloaded();

QingJ © 2025

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