你正在訪問的內容是外部程式的映像位址,僅用於使用者加速訪問,本站無法保證其可靠性。當前的連結位址(單點即可複製)為 https://greasyfork.org.cn/zh-CN/scripts/34049-youtube-like-dislike-video-and-skip-ad-keyboard-shortcuts/discussions/134050,源站連結 點此以跳轉。
Adds keyboard shortcuts [ and ] for liking and disliking videos, and s for skipping pre-video and banner ads.
< 脚本 Youtube like/dislike video and skip ad keyboard shortcuts 的反馈
Actually that's being a little flaky... this might work better:
videoinfo = document.getElementsByTagName("ytd-watch-metadata");
if(videoinfo.length >= 1) {
buttons = videoinfo[0].getElementsByTagName("ytd-toggle-button-renderer");
like = buttons[0];
dislike = buttons[1];
}
This doesn't work in the latest youtube after last week's update. Any thoughts?
Nevermind, switching to another available script recently updated.
Nevermind, switching to another available script recently updated.
What script did you switch to?
Here's a new version that works (with no skippind key shortcut anymore):
// ==UserScript==
// @name Youtube like/dislike video and skip ad keyboard shortcuts
// @namespace nerevar009
// @include https://www.youtube.com/*
// @description Adds keyboard shortcuts [ and ] for liking and disliking videos
// @version 1.2
// @grant none
// ==/UserScript==
var onvideopage, like, dislike, tag;
onvideopage = true;
if(!/^\/watch/.test(location.pathname)) onvideopage = false;
addEventListener("keypress", function(e) {
if(!onvideopage)
return;
if(e.target.getAttribute("contenteditable") == "true")
return;
tag = e.target.tagName.toLowerCase();
if(tag == "input" || tag == "textarea")
return;
like=document.getElementById("segmented-like-button").children[0].children[0].children[0];
dislike=document.getElementById("segmented-dislike-button").children[0].children[0].children[0];
if(e.code == "BracketLeft" && like)
like.click();
else if(e.code == "BracketRight" && dislike)
dislike.click();
});
To fix this for current (2022-05-14) youtube, do this:
Change:
videoinfo = document.getElementsByTagName("ytd-video-primary-info-renderer");
if(videoinfo.length == 1) {
To:
videoinfo = document.getElementsByTagName("ytd-menu-renderer");
if(videoinfo.length >= 1) {