Battle Cats Auto Display

Auto-show enemy lists

当前为 2025-04-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Battle Cats Auto Display
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description Auto-show enemy lists
  6. // @author HmmmE
  7. // @match https://ponosgames.com/information/appli/battlecats/stage/*
  8. // @grant none
  9. // @require https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // 기존 기능: 적 리스트 자동 표시
  16. function tryRunScript() {
  17. const ready = typeof setCurrentStageIndex === "function" &&
  18. document.querySelector('[id$="enemy_list_1"]');
  19.  
  20. if (!ready) return false;
  21.  
  22. // 1. Set high stage index
  23. setCurrentStageIndex(10000);
  24.  
  25. // 2. Show all *_enemy_list_1
  26. document.querySelectorAll('[id$="enemy_list_1"]').forEach(function(el) {
  27. if (el.id.startsWith("stage") && el.id.includes("_enemy_list_1")) {
  28. el.style.display = "";
  29. }
  30. });
  31.  
  32. // 3. Show all *_enemy_list
  33. document.querySelectorAll('[id$="enemy_list"]').forEach(function(el) {
  34. if (el.id.startsWith("stage") && el.id.includes("_enemy_list")) {
  35. el.style.display = "";
  36. }
  37. });
  38. return true;
  39. }
  40.  
  41. // 지연 실행
  42. const delayTime = 100; // 0.1초
  43. setTimeout(function() {
  44. const interval = setInterval(() => {
  45. const success = tryRunScript();
  46. if (success) clearInterval(interval);
  47. }, 300);
  48. }, delayTime);
  49.  
  50. // 추가 기능: Ctrl + Shift + S로 <article> 캡처
  51. document.addEventListener('keydown', function(e) {
  52. if (e.ctrlKey && e.shiftKey && e.code === 'KeyS') {
  53. e.preventDefault();
  54.  
  55. const article = document.querySelector('article');
  56. if (!article) {
  57. alert('<article> 요소를 찾을 수 없습니다.');
  58. return;
  59. }
  60.  
  61. html2canvas(article).then(canvas => {
  62. // 파일명 생성 로직
  63. const urlPath = new URL(window.location.href).pathname;
  64. const pathParts = urlPath.split('/');
  65.  
  66. let filename = 'stage';
  67. const stageIndex = pathParts.indexOf('stage');
  68. if (stageIndex !== -1) {
  69. const maybeLang = pathParts[stageIndex + 1];
  70. const maybeStage = pathParts[stageIndex + 2] || maybeLang;
  71.  
  72. if (maybeStage.endsWith('.html')) {
  73. if (maybeLang !== undefined && maybeLang !== maybeStage) {
  74. filename += `_${maybeLang}`;
  75. }
  76. filename += `_${maybeStage.replace('.html', '')}`;
  77. }
  78. }
  79.  
  80. // 이미지 저장
  81. const link = document.createElement('a');
  82. link.download = `${filename}.png`;
  83. link.href = canvas.toDataURL();
  84. link.click();
  85. });
  86. }
  87. });
  88. })();