Random Video For Youtube

Play Random Video in Youtube

  1. // ==UserScript==
  2. // @name Random Video For Youtube
  3. // @name:fr Video Aléatoire Pour Youtube
  4. // @name:en Random Video For Youtube Video
  5. // @namespace http://tampermonkey.net/
  6. // @author TrouveMe
  7. // @version 0.3.1
  8. // @contributionURL https://www.paypal.com/donate/?cmd=_donations&business=boiskarine59960@gmail.com&item_name=Greasy+Fork+donation
  9. // @description Play Random Video in Youtube
  10. // @description:fr Lance Video Aléatoire sur Youtube
  11. // @description:en Play Random Video in Youtube Video
  12. // @match https://www.youtube.com/*
  13. // @match https://www.youtu.be/*
  14. // @grant none
  15. // @license MIT
  16. // ==/UserScript==
  17.  
  18. (function() {
  19. 'use strict';
  20.  
  21. function getRandomInt(min, max) {
  22. return Math.floor(Math.random() * (max - min + 1)) + min;
  23. }
  24.  
  25. function clickRandomNthItem(selector) {
  26. let items = document.querySelectorAll(selector);
  27. let randomIndex = getRandomInt(0, items.length - 1);
  28. if (items[randomIndex]) {
  29. items[randomIndex].click();
  30. }
  31. }
  32.  
  33. function createButton() {
  34. const button = document.createElement('button');
  35. //button.innerText = "Lancer musique aléatoire";
  36. const imgbtn = new Image(32, 32)
  37. imgbtn.src = "https://www.svgrepo.com/show/458362/sort-random.svg"
  38. imgbtn.alt = "Picture For Random Button / Image Pour le Bouton Aléatoire"
  39. button.appendChild(imgbtn)
  40. button.style.position = 'fixed';
  41. button.style.top = '90%';
  42. button.style.right = '1.5%';
  43. button.style.zIndex = 1000;
  44. button.style.padding = '10px';
  45. button.style.backgroundColor = '#1DB954';
  46. button.style.color = '#FFFFFF';
  47. button.style.border = 'none';
  48. button.style.borderRadius = '5px';
  49. button.style.cursor = 'pointer';
  50. button.addEventListener('mouseover', () => { button.style.backgroundColor = '#1a8a41'})
  51. button.addEventListener('mouseout', () => { button.style.backgroundColor = '#1DB954'})
  52. button.addEventListener('mousedown', () => { button.style.backgroundColor = '#166e35'})
  53. button.addEventListener('mouseup', () => { button.style.backgroundColor = '#1DB954'})
  54.  
  55.  
  56.  
  57. button.addEventListener('click', function() {
  58. clickRandomNthItem('a#thumbnail.yt-simple-endpoint.inline-block.style-scope.ytd-thumbnail');
  59. button.style.top = '85%';
  60.  
  61. });
  62. document.body.appendChild(button);
  63. }
  64.  
  65. // Attendre que la page soit entièrement chargée avant de créer le bouton
  66. window.addEventListener('load', createButton);
  67.  
  68. })();

QingJ © 2025

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