Reload on YouTube Error

Reload the page if a YouTube adblock error occurs

目前为 2024-08-22 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Reload on YouTube Error
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @license MIT
  6. // @description Reload the page if a YouTube adblock error occurs
  7. // @author TallTacoTristan
  8. // @match *://www.youtube.com/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. const observer = new MutationObserver(() => {
  15. const errorElement = document.querySelector('.ytp-error');
  16. if (errorElement && errorElement.style.display!== 'none') {
  17. window.location.reload();
  18. }
  19. });
  20. observer.observe(document.body, { childList: true, subtree: true });
  21. })();