此脚本将 YouTube 评论部分中的“handle”替换为用户名
It is working fine in my environment...
Are you using some other script?
After some additional tests to see the compatibility with other scripts that I use, when these 2 scripts or one of them is activated your script doesn't work anymore :
- https://gf.qytechs.cn/scripts/431573
- https://gf.qytechs.cn/scripts/424068
Do you have any idea what could be wrong please ?
Now that we've identified the problem.
I probably fixed it!
Hello,
Now with the new version of your script, everything works fine.
Thank you very much for your work, your super script and because we can finally see again the real usernames in the comments of YouTube like before ;-)
Hi, I am the author of https://gf.qytechs.cn/scripts/431573
I found that setInterval(...)
is used in your script. My script will believe this is invalid operation and therefore it will only fire once.
You might consider to change it to setInterval(..., 100)
. The fastest it can achieve is setInterval(..., 1)
.
As your interval is just to check the new elements, setInterval(..., 80)
should be sufficient for this task.
Please consider to use a lower rate to avoid making YouTube laggy.
Besides, pageChangeObserver
can be replaced by document.addEventListener('yt-navigate-finish', ... , false)
or document.addEventListener('yt-page-data-fetched', ... , false)
(yt-page-data-fetched
is the event that confirmed the page has been changed but DOM is still being generating; yt-navigate-finish
is the event after yt-page-data-fetched
that DOM are ready)
Also,
if (pageName === "watch" || pageName === "shorts") {
clearInterval(commentReplaceInterval);
commentReplaceInterval = runCommentsReplace(pageChangeOb);
}
should be corrected to
clearInterval(commentReplaceInterval);
if (pageName === "watch" || pageName === "shorts") {
commentReplaceInterval = runCommentsReplace(pageChangeOb);
}
This script is not designed to run on low-spec PCs where setInterval will degrade performance ^^.
Hello,
With the new version 0.2.2 on my side :-(
In the community section of a channel :
- The names of the users and the channel owner don't appear
- Neither with the script nor with the Chrome extension
- Even with Tampermonkey and Violentmonkey disabled, but keeping only the Chrome extension
It's always the same result...
Examples :
- https://www.youtube.com/channel/UCygHXRAXTsb8JyOeauUVlmA/community?lb=UgkxOMvok43bcHa-jSeYWybXUNwWg95kneHE
- https://www.youtube.com/channel/UCygHXRAXTsb8JyOeauUVlmA/community?lb=UgkxTUMlA5vQqlS8UsfDhhNe6NPZCfNNy9Re
In the comments under videos, it's random :
- Sometimes the names of the users and the channel owner don't appear
- Sometimes the channel owner's name don't appear
- When you scroll down and further in the comments
Thank you for every bug report. To prevent the problem of names not being replaced correctly on certain pages, I have modified the replacement process to start on all pages. However, I have no intention of resolving the issue of the comments under the videos not being replaced. The reason for the problem is that the "YouTube CPU Tamer by AnimationFrame" has a setInterval rate limitation. I do not believe that one script should replace the JavaScript standard setInterval." The author of "YouTube CPU Tamer by AnimationFrame" has requested that the rate be limited to 1ms, but I disagree with that policy. 1ms is not enough time for the comment replacement to keep up with the user scrolling. You cannot sacrifice performance to maintain compatibility with one script. I am sorry, but you have two options: remove the "YouTube CPU Tamer by AnimationFrame" or remove my script.
Hello,
With the new version 0.2.2 on my side :-(
In the community section of a channel :
- The names of the users and the channel owner don't appear
- Neither with the script nor with the Chrome extension
- Even with Tampermonkey and Violentmonkey disabled, but keeping only the Chrome extension
It's always the same result...
Examples :
- https://www.youtube.com/channel/UCygHXRAXTsb8JyOeauUVlmA/community?lb=UgkxOMvok43bcHa-jSeYWybXUNwWg95kneHE
- https://www.youtube.com/channel/UCygHXRAXTsb8JyOeauUVlmA/community?lb=UgkxTUMlA5vQqlS8UsfDhhNe6NPZCfNNy9Re
In the comments under videos, it's random :
- Sometimes the names of the users and the channel owner don't appear
- Sometimes the channel owner's name don't appear
- When you scroll down and further in the comments
As you have mentioned that "Neither with the script nor with the Chrome extension" and "Even with Tampermonkey and Violentmonkey disabled, but keeping only the Chrome extension", I believe the issue is not merely because of the "YouTube CPU Tamer by AnimationFrame".
I believe that the experimental feature will implement to all users soon, therefore I created my own version to handle such problem.
You might try another script #468740 (which uses another approach) to deal with the "@username" problem by considering all the issues you mentioned.
@yakisova41 さん。実は、遅延の制約があるので、setInterval(f)
とsetInterval(f, 1)
同じです。 私もCodingのことを学んでいますから、Codingの問題を申し出すのはただGreasyForkのUserscriptがよくなって欲しいです。yakisova41さんに怒らされるのは申し訳ございません。
Thank you for every bug report.
To prevent the problem of names not being replaced correctly on certain pages, I have modified the replacement process to start on all pages. However, I have no intention of resolving the issue of the comments under the videos not being replaced. The reason for the problem is that the "YouTube CPU Tamer by AnimationFrame" has a setInterval rate limitation. I do not believe that one script should replace the JavaScript standard setInterval." The author of "YouTube CPU Tamer by AnimationFrame" has requested that the rate be limited to 1ms, but I disagree with that policy. 1ms is not enough time for the comment replacement to keep up with the user scrolling. You cannot sacrifice performance to maintain compatibility with one script. I am sorry, but you have two options: remove the "YouTube CPU Tamer by AnimationFrame" or remove my script.
Okay, I see and thank you for your reply.
Firstly, I've disabled all the scripts that I use for YouTube except your script and here's the result...
Secondly, in the community section of a channel :
- Only the names of the first users appear
- In the additional answers, the names of the users and the channel owner don't appear
Thirdly, in the comments under videos :
- The names of the users and the channel owner don't appear and same in the additional answers
Fourthly, with your extension in the community section of a channel :
- Sometimes all the names appear, but in the additional answers the names of the users and the channel owner don't appear
- Sometimes only the names of the first users appear
- Sometimes all is good because all the names appear
Fifthly, in the comments under videos, it's always random
- Sometimes the names of the users and the channel owner don't appear and same in the additional answers
- Sometimes all is good because all the names appear
It's really incredible the random change of a post or a video O_O ?!
Sixthly, after several new tests these last hours, I've found the culprit...
It's because of this extension for Chrome which I've been using since 2019 and that was recently updated -> https://chrome.google.com/webstore/detail/improve-youtube-%F0%9F%8E%A7-for-yo/bnomihfieiccainjcjblhegjgglakjdd
However, there was no problem in the past, before that YouTube made more new changes these last days and that this extension was updated.
Seventhly, I've tested the version 0.1.6 of your script, which works very well with the Chrome extension mentioned above and with YouTube CPU Tamer by AnimationFrame also for the comments under videos :-)
Eighthly, your script and your extension work very well without 'Improve YouTube!' 🎧 (for YouTube & Videos) ;-)
Ninthly, I'm glad now that I know a little better about the current situation...
Here is the final result on my side.
I have found why Improve YouTube
will make the script not working.
In your script,
const href = channelLink?.getAttribute("href");
if (channelLink !== null && typeof href === "string") {
void getUserName(href.split("/")[2]).then((name) => {
replacedElement(channelNameSpan, name);
});
}
is used.
When Improve YouTube
changes the default channel page from "HOME" to "VIDEOS"
it will also change the comment hrefs.
/channel/UCRmLncxsQFcOOC8OhzUIfxQ
will become https://www.youtube.com/channel/UCRmLncxsQFcOOC8OhzUIfxQ/videos
Therefore, href.split("/")[2]
will become www.youtube.com
I'm not sure anymore, so... I rewrote the whole code 😡😡😤😤😤. Now I can use both "Improve YouTube" and "YouTube CPU Tamer byAnimationFrame"!
I have found why Improve YouTube will make the script not working.
In your script,
const href = channelLink?.getAttribute("href");
if (channelLink !== null && typeof href === "string") {
void getUserName(href.split("/")[2]).then((name) => {
replacedElement(channelNameSpan, name);
});
}is used.
When Improve YouTube changes the default channel page from "HOME" to "VIDEOS"
it will also change the comment hrefs./channel/UCRmLncxsQFcOOC8OhzUIfxQ will become https://www.youtube.com/channel/UCRmLncxsQFcOOC8OhzUIfxQ/videos
Therefore, href.split("/")[2] will become www.youtube.com
そんなにワイのスクリプトに口出ししたいなら 至急githubにプルリクくれや😎
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址
Hello,
Unfortunately after installing the script, I don't see the names of YouTube users in the comments like before because I keep seeing @newname...
Thank you for your answer.
Google Chrome Browser with Tampermonkey or Violentmonkey