get unofficial coverage on map-making page
当前为
// ==UserScript==
// @name Unofficial Coverge Resolver
// @namespace https://greasyfork.org/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);
})();