Skip to content

Instantly share code, notes, and snippets.

@jogerj
Last active July 30, 2024 09:17
Show Gist options
  • Save jogerj/5ab40acfb77e0fd3c89de7c798a3b4b8 to your computer and use it in GitHub Desktop.
Save jogerj/5ab40acfb77e0fd3c89de7c798a3b4b8 to your computer and use it in GitHub Desktop.
(DEPRECATED -- No longer needed) Replaces the old hoyoverse API called on paimon.moe with new version

Paimon.moe Wish Import fix (DEPRECATED)

Temporary fix to redirect wish import requests to use the correct hoyoverse API on paimon.moe

Installation

  1. Get tampermonkey extension for your browser https://www.tampermonkey.net/
  2. Click this link
  3. When prompted, install the script
  4. (Chrome) Go to manage extensions, enable developer mode. Close the browser and reopen to reload.
  5. Import wishes as usual (make sure script is loaded, red icon in tampermonkey)

Mirrors

Changelog

0.3.0

  • Deprecated

0.2.0

  • Added MIT license
  • Add check for url type
  • Moved namespace

0.1.0

  • Initial release
// ==UserScript==
// @name Paimon.moe Wish Import fix
// @namespace https://jogerj.com
// @version 0.3.0
// @description (DEPRECATED) Modify request body to api.paimon.moe/corsproxy on paimon.moe
// @author JogerJ
// @match https://paimon.moe/wish/import*
// @downloadUrl https://gist.github.com/jogerj/5ab40acfb77e0fd3c89de7c798a3b4b8/raw/paimon-moe-fix-wish-import.user.js
// @grant none
// @license MIT
// ==/UserScript==
// DEPRECATED
// (function() {
// 'use strict';
// console.warn('JogerJ: Wish import requests will be intercepted!');
// // Store the original fetch function
// const originalFetch = window.fetch;
// // Override the global fetch function
// window.fetch = async (...args) => {
// let [resource, init] = args;
// // Intercept corsproxy requests
// if (resource &&
// typeof resource === 'string' &&
// resource.includes('https://api.paimon.moe/corsproxy') &&
// init &&
// init.method === 'POST'
// ) {
// init.body = init.body.replace('hk4e-api-os\.hoyoverse\.com', 'public-operation-hk4e-sg.hoyoverse.com')
// }
// // Call the original fetch function with modified body
// return originalFetch(resource, init);
// };
// })();
// ==UserScript==
// @name Paimon.moe Wish Import fix
// @namespace https://jogerj.com
// @version 0.2.0
// @description Modify request body to api.paimon.moe/corsproxy on paimon.moe
// @author JogerJ
// @match https://paimon.moe/wish/import*
// @downloadUrl https://gist.github.com/jogerj/5ab40acfb77e0fd3c89de7c798a3b4b8/raw/paimon-moe-fix-wish-import.user.js
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
console.warn('JogerJ: Wish import requests will be intercepted!');
// Store the original fetch function
const originalFetch = window.fetch;
// Override the global fetch function
window.fetch = async (...args) => {
let [resource, init] = args;
// Intercept corsproxy requests
if (resource &&
typeof resource === 'string' &&
resource.includes('https://api.paimon.moe/corsproxy') &&
init &&
init.method === 'POST'
) {
init.body = init.body.replace('hk4e-api-os\.hoyoverse\.com', 'public-operation-hk4e-sg.hoyoverse.com')
}
// Call the original fetch function with modified body
return originalFetch(resource, init);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment