f-droid.org - Supplemental!

Adds more helpful links, such as link to Google Play store and etc. inside the app's page. Adds required Android OS version and last update date of the app to top of its page. Press ' / ' to focus search. And more..

  1. // ==UserScript==
  2. // @name f-droid.org - Supplemental!
  3. // @namespace a-pav
  4. // @description Adds more helpful links, such as link to Google Play store and etc. inside the app's page. Adds required Android OS version and last update date of the app to top of its page. Press ' / ' to focus search. And more..
  5. // @match *://f-droid.org/*
  6. // @version 1.0
  7. // @run-at document-end
  8. // @author a-pav
  9. // @grant none
  10. // @icon https://f-droid.org/assets/favicon-32x32.png
  11. // ==/UserScript==
  12.  
  13. // Set search input shortcut key
  14. function setSearchShortcut() {
  15. var searchInput = document.querySelector("div.search-input-wrp>input");
  16. if (!searchInput) {
  17. return
  18. }
  19.  
  20. searchInput.setAttribute("title", " press key / to search ");
  21. searchInput.setAttribute("placeholder", " / ");
  22.  
  23. window.addEventListener('keyup', function(e) {
  24. if (e.key === "/") { // or e.which: 191
  25. searchInput.focus();
  26. } else if (e.key === "Escape") { // or e.which: 27
  27. searchInput.blur();
  28. }
  29. });
  30. }
  31.  
  32. // Set Info-Title (i.e. Required OS version, last pakckage update date)
  33. function setInfoTitle() {
  34. const infoTitleID = "info-title-summary";
  35. var requiredOS = document.getElementsByClassName("package-version-requirement")[0].innerText.replace(/.*requires /, "");
  36. var lastUpdated = document.getElementsByClassName("package-version-header")[0].innerText.replace(/.*Added on /, "");
  37.  
  38. var style = `
  39. padding: 10px 0 0px 7px;
  40. border-left-style: groove;
  41. font-family: 'Roboto';
  42. font-weight: bolder;
  43. cursor: pointer;
  44. `;
  45. document.querySelector("div.package-title").innerHTML += `
  46. <div id="${infoTitleID}" title="Go to Downloads" class="package-summary" style="${style}">
  47. // ${requiredOS}
  48. <br>
  49. // Update: ${lastUpdated}
  50. </div>
  51. `;
  52.  
  53. document.getElementById(infoTitleID).addEventListener('click', function() {
  54. document.getElementById("latest").scrollIntoView({behavior: "smooth"});
  55. });
  56. }
  57.  
  58. // Set additional links
  59. function setAdditionalLinks() {
  60. var packageID = window.location.pathname.replace(/.*\/packages\//, "").split("/")[0];
  61.  
  62. document.querySelector('ul.package-links').innerHTML += `
  63. <li class="package-link">
  64. <a style="font-weight: bold;" href="https://apt.izzysoft.de/fdroid/index/apk/${packageID}?repo=archive">
  65. Archive
  66. </a>
  67. </li>
  68. <li class="package-link">
  69. <a style="font-weight: bold;" href="https://apt.izzysoft.de/fdroid/index/apk/${packageID}">
  70. Izzy Repo
  71. </a>
  72. </li>
  73. <li class="package-link">
  74. <a style="font-weight: bold;" href="https://play.google.com/store/apps/details?id=${packageID}">
  75. Google Play
  76. </a>
  77. </li>
  78. `;
  79. }
  80.  
  81. // Colapse permissions summary initially
  82. function collapsePerms() {
  83. document.getElementById("latest").querySelector(".package-version-permissions>details").removeAttribute("open");
  84. }
  85.  
  86. (function () {
  87. setSearchShortcut();
  88. if (window.location.pathname.includes("/packages/")) {
  89. // visiting package page, then:
  90. setInfoTitle();
  91. setAdditionalLinks();
  92. collapsePerms();
  93. }
  94. }());