YouTube: Force Single Column Mode

8/17/2023, 1:51:20 AM

目前为 2023-08-16 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube: Force Single Column Mode
  3. // @namespace UserScripts
  4. // @match https://www.youtube.com/*
  5. // @grant none
  6. // @unwrap
  7. // @inject-into page
  8. // @version 1.0.1
  9. // @author CY Fung
  10. // @description 8/17/2023, 1:51:20 AM
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (() => {
  15.  
  16. const Promise = (async () => { })().constructor;
  17. const { setInterval, clearInterval } = window;
  18.  
  19. if (location.pathname.indexOf('live_chat') >= 0) return;
  20.  
  21. let cid = setInterval.call(window, () => {
  22. let ywf = document.querySelector('ytd-watch-flexy[is-two-columns_]:not([hidden])');
  23. if (ywf) {
  24. ywf.removeAttribute('is-two-columns_');
  25. const ywb = ywf.ytdWatchBehavior
  26. if (typeof ywf.updateIsTwoColumnsFromBinding === 'function' && ywb && ('isTwoColumns_' in ywb)) {
  27. ywf.updateIsTwoColumnsFromBinding = function () {
  28.  
  29. };
  30. }
  31. Promise.resolve(ywf).then((ytdWatchFlexy) => {
  32. ytdWatchFlexy.ytdWatchBehavior.isTwoColumns_ = false;
  33. })
  34. clearInterval.call(window, cid);
  35. }
  36.  
  37. }, 1);
  38.  
  39. })();