Gamebanana 자동 다운로드

Gamebanana 사이트에서 다양한 태그와 클래스를 기반으로 링크 자동 클릭 및 미디어 자동 다운로드

Version au 27/12/2024. Voir la dernière version.

  1. // ==UserScript==
  2. // @name Gamebanana 자동 다운로드
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Gamebanana 사이트에서 다양한 태그와 클래스를 기반으로 링크 자동 클릭 및 미디어 자동 다운로드
  6. // @author Your Name
  7. // @match *://*gamebanana.live/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // 다운로드 설정
  15. const downloadConfig = {
  16. click: {
  17. classes: ["GreenColor"],
  18. substrings: [],
  19. tags: ["a"], // 주로 'a' 태그만 검색
  20. index: 0, // 첫 번째 링크 대상
  21. maxCount: 1 // 예시로 한 개만 다운로드하도록 설정
  22. },
  23. image: {
  24. classes: ["PrimaryPreview"],
  25. substrings: [],
  26. tags: ["a"], // 'a' 태그만 검색
  27. index: 0, // 첫 번째 링크 대상
  28. maxCount: 1 // 한 개만 다운로드
  29. },
  30. video: {
  31. classes: [],
  32. substrings: [],
  33. tags: [],
  34. index: 0,
  35. maxCount: 0
  36. }
  37. };
  38.  
  39. // 다운로드 실행 함수
  40. function executeDownloads(type) {
  41. const config = downloadConfig[type];
  42. let downloads = 0;
  43.  
  44. if (config.tags.length > 0 && config.maxCount > 0) {
  45. config.tags.forEach(tag => {
  46. const elements = document.querySelectorAll(tag);
  47. elements.forEach((element, index) => {
  48. if (downloads >= config.maxCount) return;
  49. if (index === config.index && (Array.from(element.classList).some(className =>
  50. config.classes.includes(className) || config.substrings.some(sub => className.includes(sub))))) {
  51. if (element.click && type === 'click') {
  52. console.log(`클릭할 요소 발견: ${element.tagName}, 클래스: ${element.className}`);
  53. element.click();
  54. downloads++;
  55. } else {
  56. const url = element.tagName.toUpperCase() === tag.toUpperCase() ? element.src : element.href;
  57. console.log(`다운로드할 ${type} URL 발견: ${url}`);
  58. downloadMedia(url, url.split('/').pop());
  59. downloads++;
  60. }
  61. }
  62. });
  63. });
  64. }
  65. }
  66.  
  67. // 미디어 다운로드 함수
  68. function downloadMedia(url, filename) {
  69. const xhr = new XMLHttpRequest();
  70. xhr.open("GET", url, true);
  71. xhr.responseType = "blob";
  72. xhr.onload = function () {
  73. if (xhr.status === 200) {
  74. const blob = xhr.response;
  75. const link = document.createElement('a');
  76. link.href = window.URL.createObjectURL(blob);
  77. link.download = filename;
  78. document.body.appendChild(link);
  79. link.click();
  80. document.body.removeChild(link);
  81. }
  82. };
  83. xhr.send();
  84. }
  85.  
  86. // 페이지 로드 후 다운로드 함수 호출
  87. window.addEventListener('load', () => {
  88. ['click', 'image', 'video'].forEach(type => {
  89. if (downloadConfig[type].tags.length > 0 && downloadConfig[type].maxCount > 0) {
  90. executeDownloads(type);
  91. }
  92. });
  93. });
  94.  
  95. })();