You can also display the icon only when the percentage is below 100.
!function(){const t="ytp-volume-badge";function e(){if(document.getElementById(t))return;const e=document.querySelector(".ytp-mute-button");if(!e)return;const n=document.createElement("div");n.id=t,Object.assign(n.style,{position:"absolute",padding:"1px 3px",fontFamily:"Verdana,sans-serif",right:"25px",top:"-1px",fontSize:"8px",fontWeight:"normal",color:"white",textShadow:"0 2px 0 rgba(0,0,0,.6)",backgroundColor:"transparent",borderRadius:"2px",zIndex:"9999"}),n.textContent="0",e.style.position="relative",e.appendChild(n)}e(),setInterval((function(){const n=document.getElementById(t);if(!n)return void e();const o=document.querySelector("video");if(!o)return;const r=o.volume,i=Math.round(r/.91*100),d=Math.min(i,100);n.textContent=d>=100?"":d.toString()}),500)}();
You can also display the icon only when the percentage is below 100.
!function(){const t="ytp-volume-badge";function e(){if(document.getElementById(t))return;const e=document.querySelector(".ytp-mute-button");if(!e)return;const n=document.createElement("div");n.id=t,Object.assign(n.style,{position:"absolute",padding:"1px 3px",fontFamily:"Verdana,sans-serif",right:"25px",top:"-1px",fontSize:"8px",fontWeight:"normal",color:"white",textShadow:"0 2px 0 rgba(0,0,0,.6)",backgroundColor:"transparent",borderRadius:"2px",zIndex:"9999"}),n.textContent="0",e.style.position="relative",e.appendChild(n)}e(),setInterval((function(){const n=document.getElementById(t);if(!n)return void e();const o=document.querySelector("video");if(!o)return;const r=o.volume,i=Math.round(r/.91*100),d=Math.min(i,100);n.textContent=d>=100?"":d.toString()}),500)}();