TC4Shell.com - Add Download Buttons for 7-Zip Plugins page

Add download buttons to TC4Shell.com's 7-Zip plugins listing page, so one may download from the listing page directly, without opening plugin's page.

  1. // ==UserScript==
  2. // @name TC4Shell.com - Add Download Buttons for 7-Zip Plugins page
  3. // @name:ru TC4Shell.com - Добавьте кнопки загрузки для cтраница плагинов архиватора 7-Zip
  4. // @description Add download buttons to TC4Shell.com's 7-Zip plugins listing page, so one may download from the listing page directly, without opening plugin's page.
  5. // @description:ru Добавьте кнопки загрузки на страницу списка плагинов 7-Zip TC4Shell.com, чтобы можно было загружать напрямую со страницы списка, не открывая страницу плагина.
  6. // @namespace RainSlide
  7. // @author RainSlide
  8. // @match *://www.tc4shell.com/en/7zip/
  9. // @match *://www.tc4shell.com/ru/7zip/
  10. // @version 1.2
  11. // @license blessing
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. const links = document.querySelectorAll('#content a');
  16.  
  17. if (links.length > 0) {
  18.  
  19. // const pageURL = location.origin + location.pathname;
  20. const pageURL = new URL("./", location).href;
  21.  
  22. const match = (x, arr) => arr.some( y => y === x );
  23.  
  24. const plugins = Array.from(links).filter(
  25. plugin => (
  26. plugin.href.replace(/[^/]+\/$/, "") === pageURL &&
  27. match(plugin.parentNode.tagName, ["H2", "P"])
  28. )
  29. );
  30.  
  31. if (plugins.length > 0) {
  32.  
  33. document.head.appendChild(document.createElement("style")).textContent =
  34. `#content h1 ~ div > h2 { display: flex; justify-content: space-between; }
  35. .button_download_small { height: 2em; line-height: 1; padding: .5em;
  36. font-family: inherit; font-size: .75em; background-color: #e84c3d; }
  37. .button_download_small:hover { background-color: #ff605f; }`;
  38.  
  39. plugins.forEach(
  40. plugin => {
  41.  
  42. const pluginName = plugin.textContent.split(" ", 1)[0];
  43.  
  44. const fileName = match(pluginName, ["Asar7z", "Lzip7z"])
  45. ? pluginName.replace(/7z$/, "")
  46. : pluginName;
  47.  
  48. const i18nMap = new Map([["en", "Download"], ["ru", "Скачать"]]);
  49.  
  50. const download = Object.assign(
  51. document.createElement("a"), {
  52. href: "/binary/" + fileName + ".zip",
  53. download: "",
  54. textContent: i18nMap.get(location.pathname.slice(1, 3)) || "Download"
  55. }
  56. );
  57.  
  58. switch (plugin.parentNode.tagName) {
  59. case "H2":
  60. download.className = "button button_download_small";
  61. plugin.after(download);
  62. break;
  63. case "P":
  64. plugin.after(" (", download, ")");
  65. break;
  66. }
  67.  
  68. }
  69. );
  70.  
  71. }
  72.  
  73. }

QingJ © 2025

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