Unofficial Coverge Resolver

get unofficial coverage on map-making page

目前為 2024-07-09 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Unofficial Coverge Resolver
// @namespace    https://gf.qytechs.cn/users/1179204
// @version      1.0.1
// @description  get unofficial coverage on map-making page
// @author       KaKa
// @match        *://map-making.app/maps/
// @require      https://cdn.jsdelivr.net/npm/sweetalert2@11
// @license      MIT
// @grant        unsafeWindow
// @icon         https://www.google.com/s2/favicons?domain=geoguessr.com
// ==/UserScript==

(function() {
    let preference;

    function showAlert(preference) {
        Swal.fire({
            title: 'Preference',
            text: `The default coverage has been set to "${preference}"`,
            icon: 'info',
            timer: 2000,
            showConfirmButton: false,
        });
    }
    const THE_WINDOW = unsafeWindow || window;

    THE_WINDOW.fetch = function(originalFetch) {
        return function (...args) {
            const url = args[0].toString();
            if (url.includes('SingleImageSearch')||url.includes('GetMetadata')) {
                if (args[1] && args[1].method === 'POST') {
                    if (preference=='Unofficial'){
                        var requestData = JSON.parse(args[1].body);
                        if (url.includes('SingleImageSearch')) requestData[2][10][0][0][0]=3
                        if (url.includes('GetMetadata')) requestData[2][0][0][0]=10
                        args[1].body=JSON.stringify(requestData)
                    }
                }
                try {
                    const response = originalFetch.apply(THE_WINDOW, args);
                    return response
                } catch (error) {
                    console.error('Fetch error:', error);
                    throw error;
                }
            }

            return originalFetch.apply(THE_WINDOW, args);
        };
    }(THE_WINDOW.fetch);

    let onKeyDown = (e) => {
        if (e.key === 'q' || e.key === 'Q') {
            e.stopImmediatePropagation();
            if(preference!='Unofficial')preference='Unofficial'
            else preference='Official'
            showAlert(preference)
        };
    }
    document.addEventListener("keydown", onKeyDown);
})();

QingJ © 2025

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