Ubuntu/Debian package cross link

Link between Debian and Ubuntu package page

  1. // ==UserScript==
  2. // @name Ubuntu/Debian package cross link
  3. // @description Link between Debian and Ubuntu package page
  4. // @namespace https://franklinyu.github.io
  5. // @version 0.1.0
  6. // @match https://packages.debian.org/*
  7. // @exclude https://packages.debian.org/about/*
  8. // @exclude https://packages.debian.org/search?*
  9. // @exclude https://packages.debian.org/*/filelist
  10. // @exclude https://packages.debian.org/*/download
  11. // @match https://packages.ubuntu.com/*
  12. // @exclude https://packages.ubuntu.com/about/*
  13. // @exclude https://packages.ubuntu.com/search?*
  14. // @exclude https://packages.ubuntu.com/*/filelist
  15. // @exclude https://packages.ubuntu.com/*/download
  16. // @grant none
  17. // ==/UserScript==
  18.  
  19. let url
  20. let text
  21. if (location.hostname === 'packages.debian.org') {
  22. url = new URL('https://packages.ubuntu.com/search')
  23. text = 'Ubuntu'
  24. } else {
  25. url = new URL('https://packages.debian.org/search')
  26. text = 'Debian'
  27. }
  28. url.searchParams.append('exact', 1)
  29.  
  30. if (location.pathname.startsWith('/source/')) {
  31. const package = location.pathname.split('/')[3]
  32. if (!package)
  33. throw location.pathname
  34. url.searchParams.append('keywords', package)
  35. url.searchParams.append('searchon', 'sourcenames')
  36. } else {
  37. const package = location.pathname.split('/')[2]
  38. if (!package)
  39. throw location.pathname
  40. url.searchParams.append('keywords', package)
  41. }
  42.  
  43. const anchor = document.createElement('a')
  44. anchor.href = url
  45. anchor.innerText = text
  46. document.getElementById('pothers').innerHTML += ` [ ${anchor.outerHTML} ]`

QingJ © 2025

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