GI AppSample Map - More Markable Markers

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

< 脚本GI AppSample Map - More Markable Markers的反馈

评价:好评 - 脚本运行良好

§
发布于:2025-05-24
编辑于:2025-05-24

✅ Updated Userscript for Genshin Impact Map — Now Supports markers_all.v4.json

Genshin Impact Map Icon

Hi everyone,

I’ve updated my userscript to support the recent filename change on genshin-impact-map.appsample.com, where the marker file is now named markers_all.v4.json.

This version introduces flexible filename matching, allowing the script to work with any marker file that starts with markers_all, regardless of versioning or suffix.


🧠 Key Features

  • ✅ Flexible filename support
  • ✅ Compatible with markers_all.v4.json
  • ✅ Future-proof against file renaming
  • ✅ Enables marker editing and comments

📁 Filename Change Confirmation

Screenshot showing the updated filename on the network request:

file-name.png


✅ Script Working Example

Screenshot showing that the script works correctly with the new marker file:

its-work.png


📝 Userscript Code Sample

// ==UserScript==
// @name         GI AppSample Map - More Markable Markers (v4 fix)
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Modifies markers on the Genshin map to be markable and commentable. Also supports new v4.json files.
// @author       2KRN4U
// @match        https://genshin-impact-map.appsample.com/*
// @icon         https://genshin-impact-map.appsample.com/favicon.ico
// @grant        none
// ==/UserScript==

// ... full code here ...

this._filename.startsWith("markers_all"); // ✅ Flexible filename match
// ==UserScript==
// @name         GI AppSample Map - More Markable Markers (v4 fix)
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Modifies markers on the Genshin map to be markable and commentable. Also supports new v4.json files.
// @author       2KRN4U + FIX 
// @match        https://genshin-impact-map.appsample.com/*
// @icon         https://genshin-impact-map.appsample.com/favicon.ico
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // Comma-separated list of marker IDs to modify – you can change this
    const list = "o596, o601, o666, o602, o639, o641, o647, o409, o128, o416 ,o415";
    const keys = list.split(",").map(key => key.trim());

    // Value that enables marking and commenting – usually 5
    const allowMarkComment = 5;

    const originalOpen = XMLHttpRequest.prototype.open;
    const originalSend = XMLHttpRequest.prototype.send;

    // Intercept the request to save the file name
    XMLHttpRequest.prototype.open = function (method, url, async, user, password) {
        this._filename = url.split('/').pop();
        this._url = url;
        originalOpen.apply(this, arguments);
    };

    // Intercept the response and modify it if it's the marker file
    XMLHttpRequest.prototype.send = function (body) {
        this.addEventListener('readystatechange', function () {
            if (
                this.readyState === 4 &&
                this.status === 200 &&
                this._filename &&
                this._filename.startsWith("markers_all") // Also catches markers_all.v4.json
            ) {
                try {
                    let modifiedResponseText = this.responseText;

                    // Modify the values for specified marker IDs
                    keys.forEach(key => {
                        const searchPattern = new RegExp(`("${key}",\\d+,)(\\d+)(,)`, 'g');
                        modifiedResponseText = modifiedResponseText.replace(
                            searchPattern,
                            (_, prefix, lastDigits, suffix) => `${prefix}${allowMarkComment}${suffix}`
                        );
                    });

                    // Override the responseText and response properties
                    Object.defineProperty(this, 'responseText', {
                        value: modifiedResponseText,
                        configurable: true,
                    });

                    Object.defineProperty(this, 'response', {
                        value: modifiedResponseText,
                        configurable: true,
                    });
                } catch (e) {
                    console.error('Error while modifying JSON:', e);
                }
            }
        });

        originalSend.apply(this, arguments);
    };

    // After the page loads, modify button tooltips to include data-testid
    window.addEventListener('load', function () {
        const modifyTitle = (originalTitle, dataTestId) => {
            const trimmedData = dataTestId ? dataTestId.slice(4) : 'Unknown';
            return `${originalTitle}: ${trimmedData}`;
        };

        const buttons = document.querySelectorAll('.MuiButtonBase-root');
        buttons.forEach(button => {
            const originalTitle = button.getAttribute('title');
            const dataTestId = button.getAttribute('data-testid');

            if (originalTitle && dataTestId) {
                const newTitle = modifyTitle(originalTitle, dataTestId);
                button.setAttribute('title', newTitle);
            }
        });
    });
})();

✨ Hope this code helped you! 🙏

If it solved your problem or improved your experience with the Genshin Impact map –
I’d really appreciate your feedback, a star ⭐, or any kind of comment!


💡 Have ideas for improvements or updates?

Feel free to update the source code or share your suggestions here. I’m continuously working on improving the script as needed.


🔗 Sharing? Please give credit to 2KRN4U + Hebrew Fix — much appreciated! 🙌


💻 Thanks and enjoy marking!
🎮 Genshin players unite 💚

发表回复

登录以发表回复。