您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Allows you to zoom in on YouTube videos. Useful to get rid of black borders at the top/bottom of a video if you have an ultrawide display.
当前为
- // ==UserScript==
- // @name Video zooming buttons
- // @description Allows you to zoom in on YouTube videos. Useful to get rid of black borders at the top/bottom of a video if you have an ultrawide display.
- // @version 1
- // @grant none
- // @match https://www.youtube.com/*
- // @namespace https://greasyfork.org/users/442760
- // ==/UserScript==
- function prepareButton(b)
- {
- b.style.float = "right";
- }
- function getVideo()
- {
- return document.querySelector(".html5-main-video");
- }
- console.log("Start waiting");
- var waitInterval = setInterval(function() {
- var elemTitle = document.querySelector("yt-formatted-string.ytd-video-primary-info-renderer:nth-child(1)");
- if (!elemTitle || !getVideo()) {
- return;
- }
- clearInterval(waitInterval);
- console.log("Clear interval");
- var zoomSpeed = 0.0;
- var zoom = 1.0;
- setInterval(function() {
- var video = getVideo();
- if (video) {
- zoom += zoomSpeed;
- video.style.transform = "scale(" + zoom + ")";
- }
- }, 17);
- var newButtonIncrease = document.createElement("button");
- newButtonIncrease.innerText = "+";
- prepareButton(newButtonIncrease);
- var newButtonDecrease = document.createElement("button");
- newButtonDecrease.innerText = "-";
- prepareButton(newButtonDecrease);
- var newButtonReset = document.createElement("button");
- newButtonReset.innerText = "Reset";
- prepareButton(newButtonReset);
- newButtonIncrease.onmousedown = function() { zoomSpeed = 0.01; };
- newButtonIncrease.onmouseup = function() { zoomSpeed = 0; };
- newButtonDecrease.onmousedown = function() { zoomSpeed = -0.01; };
- newButtonDecrease.onmouseup = function() { zoomSpeed = 0; };
- newButtonReset.onclick = function() { zoom = 1.0; }
- elemTitle.appendChild(newButtonIncrease);
- elemTitle.appendChild(newButtonDecrease);
- elemTitle.appendChild(newButtonReset);
- console.log(elemTitle);
- console.log("Everything done");
- }, 500);