GI AppSample Map - More Markable Markers

Gets the markers_all json file and change user defined markers to be markable.

  1. // ==UserScript==
  2. // @name GI AppSample Map - More Markable Markers
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description Gets the markers_all json file and change user defined markers to be markable.
  6. // @author 2KRN4U
  7. // @match https://genshin-impact-map.appsample.com/*
  8. // @icon https://genshin-impact-map.appsample.com/favicon.ico
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15.  
  16. // List of markers to change
  17. const list = "o596, o601, o602, o639, o641, o647, o128"; // EDIT THIS LINE ONLY, seperate by comma. Example "o596, o317";
  18.  
  19. const targetFilenameStart = "markers_all"; // Filename of the markers file
  20.  
  21. const keys = list.split(",").map(key => key.trim()); // Convert list to an array of trimmed keys
  22.  
  23. const allowMarkComment = 5; // Value to allow marking and commenting
  24.  
  25. // Save references to the original XHR methods
  26. const originalOpen = XMLHttpRequest.prototype.open;
  27. const originalSend = XMLHttpRequest.prototype.send;
  28.  
  29. // Override the open method
  30. XMLHttpRequest.prototype.open = function (method, url, async, user, password) {
  31. this._filename = url.split('/').pop(); // Extract the filename from the URL
  32. this._url = url; // Store the URL for later use
  33. originalOpen.apply(this, arguments); // Call the original open method
  34. };
  35.  
  36. // Override the send method
  37. XMLHttpRequest.prototype.send = function (body) {
  38. this.addEventListener('readystatechange', function () {
  39. // Only process requests if the filename matches the target prefix
  40. if (
  41. this.readyState === 4 &&
  42. this.status === 200 &&
  43. this._filename.startsWith(targetFilenameStart) // Check if filename starts with the target string
  44. ) {
  45. try {
  46. let modifiedResponseText = this.responseText;
  47.  
  48. // Apply replacements for each key in the list
  49. keys.forEach(key => {
  50. const searchPattern = new RegExp(`("${key}",\\d+,)(\\d+)(,)`, 'g'); // Search pattern for markers
  51. modifiedResponseText = modifiedResponseText.replace(
  52. searchPattern,
  53. (_, prefix, lastDigits, suffix) => `${prefix}${allowMarkComment}${suffix}`
  54. ); // Replace to allow marking and commenting
  55. });
  56.  
  57. // Overwrite the responseText property with the modified content
  58. Object.defineProperty(this, 'responseText', {
  59. value: modifiedResponseText,
  60. configurable: true,
  61. });
  62.  
  63. // Optional: Overwrite response (useful if response is accessed differently)
  64. Object.defineProperty(this, 'response', {
  65. value: modifiedResponseText,
  66. configurable: true,
  67. });
  68. } catch (e) {
  69. console.error('Error modifying JSON response:', e);
  70. }
  71. }
  72. });
  73.  
  74. // Call the original send method
  75. originalSend.apply(this, arguments);
  76. };
  77.  
  78. // Wait for the DOM to fully load
  79. window.addEventListener('load', function () {
  80. // Function to modify the title
  81. const modifyTitle = (originalTitle, dataTestId) => {
  82. // Trim the first 4 characters of data-testid
  83. const trimmedData = dataTestId ? dataTestId.slice(4) : 'Unknown';
  84. // Combine the original title with the trimmed data-testid
  85. return `${originalTitle}: ${trimmedData}`;
  86. };
  87.  
  88. // Select all buttons with the class "MuiButtonBase-root"
  89. const buttons = document.querySelectorAll('.MuiButtonBase-root');
  90.  
  91. // Iterate over each button
  92. buttons.forEach(button => {
  93. const originalTitle = button.getAttribute('title');
  94. const dataTestId = button.getAttribute('data-testid');
  95.  
  96. // Only proceed if both title and data-testid exist
  97. if (originalTitle && dataTestId) {
  98. const newTitle = modifyTitle(originalTitle, dataTestId);
  99. button.setAttribute('title', newTitle);
  100. }
  101. });
  102. });
  103. })();

QingJ © 2025

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