Youtube removes clickbait from thumbnails

Removes clickbait from thumbnails changing to start/middle/end thumb of video

目前为 2024-04-06 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Youtube removes clickbait from thumbnails
  3. // @namespace https://gf.qytechs.cn/users/821661
  4. // @match https://www.youtube.com/*
  5. // @grant GM_registerMenuCommand
  6. // @grant GM_setValue
  7. // @grant GM_getValue
  8. // @version 0.1
  9. // @author hdyzen
  10. // @description Removes clickbait from thumbnails changing to start/middle/end thumb of video
  11. // @license MIT
  12. // ==/UserScript==
  13. 'use strict';
  14.  
  15. const optionsMenu = {
  16. start: 'hq1',
  17. middle: 'hq2',
  18. end: 'hq3',
  19. default: 'hqdefault',
  20. };
  21.  
  22. let optionSelected = GM_getValue('optionSelected', optionsMenu['start']);
  23.  
  24. function createMenu() {
  25. Object.keys(optionsMenu).forEach(id => {
  26. let optionAtual = optionsMenu[id];
  27. GM_registerMenuCommand(
  28. `${optionAtual === optionSelected ? '[⬤]' : '[◯]'} Use thumbnail from ${id}`,
  29. e => {
  30. GM_setValue('optionSelected', optionAtual);
  31. optionSelected = optionAtual;
  32. createMenu();
  33. changeThumbsAfter();
  34. },
  35. { autoClose: false, id: optionAtual },
  36. );
  37. });
  38. }
  39.  
  40. function changeThumbsAfter() {
  41. const thumbs = document.querySelectorAll('a#thumbnail > .ytd-thumbnail > img[src]');
  42. thumbs.forEach(thumb => {
  43. thumb.src = thumb.src.replace(/(?<=\/)hq[a-z0-9]+/, optionSelected);
  44. });
  45. }
  46.  
  47. function changeThumbsOnInit() {
  48. document.addEventListener('image-loaded', e => {
  49. if (!e.target.src.includes(`${optionSelected}.`)) {
  50. e.target.src = e.target.src.replace(/(?<=\/)hq[a-z0-9]+/, optionSelected);
  51. }
  52. });
  53. }
  54.  
  55. createMenu();
  56. changeThumbsOnInit();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址