您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Try to fix the performance issues that youtube music has
- // ==UserScript==
- // @name Youtube Music fix performance
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description Try to fix the performance issues that youtube music has
- // @author Marco Pfeiffer <git@marco.zone>
- // @match https://music.youtube.com/*
- // @icon https://music.youtube.com/favicon.ico
- // @run-at document-start
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- const global = window.unsafeWindow ?? window;
- const setInterval = global.setInterval;
- const clearInterval = global.clearInterval;
- const intervals = new Set();
- global.setInterval = function(fn, ms) {
- const n = setInterval.call(this, fn, ms);
- console.log("setup interval", n, fn, ms, "still pending timers", Array.from(intervals));
- intervals.add(n);
- return n;
- };
- global.clearInterval = function (n) {
- if (!intervals.delete(n)) {
- console.log("failed cleanup of", n, "still pending timers", Array.from(intervals));
- if (intervals.size > 5) {
- const timersToCleanUp = Array.from(intervals).slice(0, -5);
- console.log("cleanup timers", timersToCleanUp);
- timersToCleanUp.forEach(clearInterval);
- }
- } else {
- console.log("cleanup interval", n, "still pending timers", Array.from(intervals));
- }
- return clearInterval.call(this, n);
- };
- })();