Youtube helper

Removes "thanks", "download", "clip" and "description" buttons, also removes "Do you want to continue?" popup in the playlist

目前為 2022-07-18 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Youtube helper
  3. // @icon https://www.youtube.com/s/desktop/a14aba22/img/favicon_144x144.png
  4. // @description Removes "thanks", "download", "clip" and "description" buttons, also removes "Do you want to continue?" popup in the playlist
  5. // @author Murka
  6. // @version 0.3
  7. // @match *://www.youtube.com/*
  8. // @run-at document-start
  9. // @grant none
  10. // @noframes
  11. // @license MIT
  12. // @namespace https://greasyfork.org/users/919633
  13. // ==/UserScript==
  14. /* jshint esversion:6 */
  15.  
  16. (function() {
  17.  
  18. const log = console.log;
  19. Object.defineProperty(window, "_lact", {
  20. get() {
  21. return Date.now();
  22. }
  23. })
  24.  
  25. function createObserver(target, callback) {
  26. const observer = new MutationObserver(function(mutations) {
  27. for (const mutation of mutations) {
  28. for (const node of mutation.addedNodes) {
  29. callback(node);
  30. }
  31. }
  32. })
  33. observer.observe(target, { childList: true, subtree: true });
  34. return observer;
  35. }
  36.  
  37. const exclude = ["OFFLINE_DOWNLOAD", "MONEY_HEART", "CONTENT_CUT", "INFO"];
  38. const observer = createObserver(document, function(node) {
  39. if (node.id !== "top-level-buttons-computed") return;
  40.  
  41. let found = false;
  42. for (const child of node.children) {
  43. const data = child.__data && child.__data.data;
  44. const iconType = data && (data.defaultIcon && data.defaultIcon.iconType || data.icon && data.icon.iconType);
  45. if (iconType && exclude.includes(iconType)) {
  46. child.style.display = "none";
  47. found = true;
  48. }
  49. child.style.fontSize = "1em";
  50. }
  51.  
  52. if (found) observer.disconnect();
  53. })
  54.  
  55. })();