您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Restores the classic Watch page layout from before 2019
当前为
- // ==UserScript==
- // @name Watch9 Reconstruct
- // @version 1.1.2
- // @description Restores the classic Watch page layout from before 2019
- // @author Aubrey
- // @namespace aubymori
- // @match https://www.youtube.com/*
- // @license MIT
- // @icon https://www.google.com/s2/favicons?domain=youtube.com
- // @grant none
- // @run-at document-start
- // ==/UserScript==
- // ok, i'm saying it now.
- // do not expect much updates of this script.
- // i have better things to do
- async function waitForElm(q) {
- while (document.querySelector(q) == null) {
- await new Promise(r => requestAnimationFrame(r));
- };
- return document.querySelector(q);
- };
- const w9rStyle = document.createElement("style");
- w9rStyle.innerHTML = `
- #w9r-sub-count {
- opacity: .8;
- margin-left: 6px;
- }
- #info-strings.ytd-video-primary-info-renderer,
- #owner-sub-count {
- display: none !important;
- }
- `;
- document.getElementsByTagName("head")[0].appendChild(w9rStyle);
- document.addEventListener("yt-page-data-updated", async function() {
- var pubDate = await waitForElm("ytd-video-primary-info-renderer");
- const pubDatePnt = pubDate.data.dateText.simpleText;
- function fixPubDate(date) {
- if (/(Premier)|(Stream)|(Start)/.test(date)) {
- return date;
- } else {
- return "Published on " + date;
- }
- }
- var subCnt = await waitForElm("ytd-video-secondary-info-renderer");
- const subCntPnt = subCnt.data.owner.videoOwnerRenderer.subscriberCountText.simpleText;
- function fixSubCnt(cnt) {
- return cnt.replace(/( subscribers)|( subscriber)/, "").replace("No", "0");
- }
- var subBtn = await waitForElm("#subscribe-button tp-yt-paper-button");
- var pubDateElm = await waitForElm(".date.ytd-video-secondary-info-renderer");
- var viewCount = await waitForElm("ytd-video-view-count-renderer");
- if (document.querySelector("#w9r-sub-count") == null) {
- var w9rSubCount = document.createElement("yt-formatted-string");
- w9rSubCount.text = {runs:[{text: subCntPnt.replace(/( subscribers)|( subscriber)/, "").replace("No", "0")}]};
- w9rSubCount.id = "w9r-sub-count";
- subBtn.querySelector("yt-formatted-string").insertAdjacentElement("afterEnd", w9rSubCount)
- } else {
- document.querySelector("#w9r-sub-count").text = {simpleText:fixSubCnt(subCntPnt)};//{runs:[{text: fixSubCnt(subCntPnt)}]};
- };
- viewCount.removeAttribute("small");
- pubDateElm.innerHTML = fixPubDate(pubDatePnt);
- });