军团珠宝跳转国服市集

跳转地址劫持

// ==UserScript==
// @name         军团珠宝跳转国服市集
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  跳转地址劫持
// @author       Rxdey
// @match        https://vilsol.github.io/timeless-jewels/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=github.io
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';
    const TRAD_URL = 'https://poe.game.qq.com/trade/search';
    const transformUrl = (url) => {
        let params = url.searchParams;
        let query = JSON.parse(decodeURIComponent(params.get('q')));
        // 识别不出英文名字类型,直接删除
        delete query.query.name;
        delete query.query.type;
        // 在线状态改成任何
        query.query.status.option = 'any';
        window.temp_Open(`${TRAD_URL}?q=${encodeURIComponent(JSON.stringify(query))}`);
    };
    window.temp_Open = window.open;
    // 劫持window.open
    window.open = (url, tag) => {
        // console.log(JSON.stringify(url));
        if (!/^https\:\/\/www\.pathofexile\.com\/trade\/search\//.test(url.href)) {
            window.temp_Open(url, tag);
            return;
        }
        transformUrl(url);
    };

})();