Archyvai.lt Downloader

Генерирует ссылки для скачивания изображений с сайта eais.archyvai.lt

安装此脚本
作者推荐脚本

您可能也喜欢ePaveldas.lt Downloader

安装此脚本
  1. // ==UserScript==
  2. // @name Archyvai.lt Downloader
  3. // @namespace nikku
  4. // @license MIT
  5. // @version 0.2
  6. // @description Генерирует ссылки для скачивания изображений с сайта eais.archyvai.lt
  7. // @author nikku
  8. // @match https://eais.archyvai.lt/repo-ext-viewer/?manifest=*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=eais.archyvai.lt
  10. // @require https://cdn.jsdelivr.net/npm/file-saver@2.0.5/dist/FileSaver.min.js
  11. // @run-at document-start
  12. // @grant unsafeWindow
  13. // ==/UserScript==
  14.  
  15. /* global saveAs */
  16.  
  17. function processData(d) {
  18. let text = '';
  19. const path = '/full/max/0/default.jpg';
  20. const file = `${d.archiveAbbr}_${d.fondNum}_${d.seriesNum}_${d.fileNum}_${d.title.slice(0, 192)} [${d.items.length}].txt`;
  21.  
  22. d.items.forEach(function(item) {
  23. text += item.items[0].items[0].body.id + path + '\r\n';
  24. });
  25.  
  26. const btnHtml = `
  27. <button id="down_links" class="MuiButtonBase-root MuiIconButton-root" type="button"
  28. title="Скачать список ссылок">
  29. <span class="MuiIconButton-label">
  30. <svg class="MuiSvgIcon-root" focusable="false" viewBox="0 0 24 24">
  31. <path d="M16 13h-3V3h-2v10H8l4 4 4-4zM4 19v2h16v-2H4z"></path>
  32. </svg>
  33. &nbsp;D/L
  34. </span>
  35. </button>`;
  36.  
  37. let stopObserve = false;
  38. const observer = new MutationObserver(function (mutList) {
  39. for (let i = 0; i < mutList.length; i++) {
  40. for (let j = 0; j < mutList[i].addedNodes.length; j++) {
  41. const added = mutList[i].addedNodes[j];
  42. if (added.classList && added.classList.contains('MuiTouchRipple-root')) {
  43. document.querySelector('.MuiToolbar-root > h2').insertAdjacentHTML('afterend', btnHtml);
  44. document.querySelector('#down_links').addEventListener('click', function() {
  45. saveAs(new Blob([text], {type: 'text/plain;charset=utf-8'}), file);
  46. });
  47. observer.disconnect();
  48. stopObserve = true;
  49. break;
  50. }
  51. }
  52. if (stopObserve) {
  53. break;
  54. }
  55. }
  56. });
  57.  
  58. observer.observe(document.body, {
  59. subtree: true, childList: true
  60. });
  61. }
  62.  
  63. (function() {
  64. 'use strict';
  65.  
  66. const origFetch = unsafeWindow.fetch;
  67. unsafeWindow.fetch = async function(arg) {
  68. const res = await origFetch(arg);
  69. if (arg.endsWith('/manifest')) {
  70. res.clone().json().then(function(json) {
  71. processData(json);
  72. });
  73. }
  74. return res;
  75. }
  76. })();