Greasy Fork 还支持 简体中文。

HeroesWM Player List Extractor

Извлечение списка игроков и их уровней для Google Sheets

  1. // ==UserScript==
  2. // @name HeroesWM Player List Extractor
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description Извлечение списка игроков и их уровней для Google Sheets
  6. // @author Cursor Agent
  7. // @match *://*.heroeswm.ru/clan_info.php*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Function to extract player names and levels
  16. function extractPlayerData() {
  17. const rows = document.querySelectorAll('tr');
  18. let result = [];
  19. rows.forEach(row => {
  20. const cells = row.querySelectorAll('td');
  21. if (cells.length >= 6) {
  22. const name = cells[2].querySelector('a')?.textContent.trim() || '';
  23. const level = cells[3].textContent.trim();
  24. if (name && level) {
  25. result.push([name, level].join('\t'));
  26. }
  27. }
  28. });
  29. return result.join('\n');
  30. }
  31.  
  32. // Function to copy data to clipboard
  33. function copyToClipboard() {
  34. const data = [
  35. 'Name\tLevel',
  36. extractPlayerData()
  37. ].join('\n');
  38.  
  39. navigator.clipboard.writeText(data)
  40. .then(() => {
  41. alert('Player data copied to clipboard! You can now paste it into Google Sheets.');
  42. })
  43. .catch(err => {
  44. console.error('Failed to copy data: ', err);
  45. alert('Failed to copy data. Please try again.');
  46. });
  47. }
  48.  
  49. // Add button to the page
  50. function addButton() {
  51. const button = document.createElement('button');
  52. button.textContent = 'Copy Names & Levels';
  53. button.style.position = 'fixed';
  54. button.style.top = '10px';
  55. button.style.right = '10px';
  56. button.style.zIndex = '9999';
  57. button.style.padding = '10px';
  58. button.style.backgroundColor = '#4CAF50';
  59. button.style.color = 'white';
  60. button.style.border = 'none';
  61. button.style.borderRadius = '5px';
  62. button.style.cursor = 'pointer';
  63. button.addEventListener('click', copyToClipboard);
  64. document.body.appendChild(button);
  65. }
  66.  
  67. // Wait for the page to load completely
  68. window.addEventListener('load', function() {
  69. setTimeout(addButton, 1000);
  70. });
  71. })();