Youtube auto rco=1

Automatically adds rco=1 to avoid "This video may be inappropriate for some users."

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name       Youtube auto rco=1
// @name:ru    Youtube авто rco=1
// @author     KN13KOMETA
// @version    1.2.1
// @namespace  https://violentmonkey.github.io

// @description       Automatically adds rco=1 to avoid "This video may be inappropriate for some users."
// @description:ru    Автоматически добавляет rco=1 чтобы избежать "Это видео может оказаться неприемлемым для некоторых пользователей."

// @supportURL  https://discord.gg/d4rKqZs
// @homepageURL https://discord.gg/d4rKqZs

// @match  https://www.youtube.com/*
// @run-at document-start

// @license UNLICENSE
// ==/UserScript==

console.log("Youtube auto rco=1 loaded");

new MutationObserver(_mut => {
  const lc = window.location;

  if (lc.pathname != "/watch") return;
  if (lc.search.indexOf("rco=1") != -1) return;

  console.log("/watch page detected, reloading page with rco=1");
  window.history.replaceState({}, null, lc.href + (lc.search.endsWith("&") ? "rco=1" : "&rco=1"));
  lc.reload();
}).observe(
  document,
  {
    subtree: true,
    childList: true
  }
);