auto download pypi whl file

auto download whl file for pypi.org

  1. // ==UserScript==
  2. // @name auto download pypi whl file
  3. // @namespace http://tampermonkey.net/
  4. // @version 2025-04-29
  5. // @description auto download whl file for pypi.org
  6. // @author russiavk
  7. // @match https://pypi.org/project/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. if(location.hash!='#files'){
  16. location.hash='#files';
  17. window.onhashchange=function(){
  18. if(location.hash==='#files'){
  19. const css_selector=`.file__card [href^="https://files.pythonhosted.org"][href$=".whl"]`;
  20. const observer = new MutationObserver((mutations) => {
  21. const element = document.querySelector(css_selector);
  22. if (element) {
  23. element.click();
  24. observer.disconnect();
  25. }
  26. });
  27. observer.observe(document.body, {
  28. childList: true,
  29. subtree: true
  30. });
  31.  
  32. }
  33.  
  34. }
  35. }
  36. })();