Greasy Fork 支持简体中文。

Sorting videos on YouTube

Sorting videos on YouTube using the floating button

目前為 2023-04-13 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Sorting videos on YouTube
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Sorting videos on YouTube using the floating button
  6. // @author You
  7. // @match https://www.youtube.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Создаем плавающую кнопку
  16. const button = document.createElement('button');
  17. button.innerHTML = 'Reverse';
  18. button.style.position = 'fixed';
  19. button.style.bottom = '20px';
  20. button.style.right = '20px';
  21. button.style.zIndex = 1000;
  22. button.style.padding = '10px 15px';
  23. button.style.fontSize = '14px';
  24. button.style.cursor = 'pointer';
  25. document.body.appendChild(button);
  26.  
  27. // Функция для переключения стилей
  28. function toggleStyles() {
  29. const styleElement = document.getElementById('reverse-styles');
  30. if (styleElement) {
  31. styleElement.remove();
  32. } else {
  33. const style = document.createElement('style');
  34. style.id = 'reverse-styles';
  35. style.innerHTML = `
  36. #contents.ytd-rich-grid-renderer {
  37. width: 100%;
  38. padding-top: 24px;
  39. display: flex;
  40. flex-wrap: wrap;
  41. justify-content: flex-start;
  42. flex-direction: column-reverse;
  43. }
  44. #contents {
  45. flex-direction: row-reverse;
  46. }
  47. `;
  48. document.head.appendChild(style);
  49. }
  50. }
  51.  
  52. // Добавляем обработчик событий клика на кнопку
  53. button.addEventListener('click', toggleStyles);
  54. })();