Greasy Fork

Greasy Fork is available in English.

Remove overlay messages on Youtube

Remove Youtube message about inappropriate or offensive content

当前为 2022-10-16 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name          Remove overlay messages on Youtube
// @description   Remove Youtube message about inappropriate or offensive content
// @author        MK
// @namespace     max44
// @homepage      http://greasyfork.icu/en/users/309172-max44
// @match         *://*.youtube.com/*
// @match         *://*.youtu.be/*
// @icon          https://cdn.icon-icons.com/icons2/1488/PNG/512/5295-youtube-i_102568.png
// @version       1.1
// @license       MIT
// @require       https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @grant         none
// @run-at        document-start
// ==/UserScript==

(function() {
  'use strict';

  var urlAtLastCheck = "";
  var divButtons = null;

  setInterval(function() { //Check page content constantly
    if (urlAtLastCheck != window.location.href.split("v=")[1].split("&")[0]) { //Check whether URL has changed
      var pathArray = window.location.pathname.split('/');
      var firstPath = pathArray[1];
      urlAtLastCheck = window.location.href.split("v=")[1].split("&")[0];

      if (firstPath === "watch") { //Process messages while watching video
        var count = 0;
        let waitError = setInterval(function() { //Wait untile message appears at the beginning of video
          count++;
          divButtons = $( "div#button.style-scope.yt-player-error-message-renderer > yt-button-renderer > a[tabindex='-1'] > tp-yt-paper-button[aria-label][aria-disabled='false']" );

          if (divButtons != null && divButtons.length >= 1) {
            clearInterval(waitError); //Stop waiting for messages
            divButtons[0].click();
          }

          if (count > 50) {
            clearInterval(waitError); //Stop waiting for messages
          }
        }, 250);
        if (divButtons != null) divButtons = null;
      }
    }
  }, 250);
})();