闲鱼适配电脑网页

解决在电脑网页端打开闲鱼链接时不能完全显示的问题,访问移动版闲鱼页面时会自动帮你跳转到对应的淘宝页面,更加方便查看信息。

// ==UserScript==
// @name         闲鱼适配电脑网页
// @namespace    http://tampermonkey/goofish-to-taobao
// @version      1.0.1
// @author       ChatGPT and me
// @license      MIT
// @description  解决在电脑网页端打开闲鱼链接时不能完全显示的问题,访问移动版闲鱼页面时会自动帮你跳转到对应的淘宝页面,更加方便查看信息。
// @match        https://h5.m.goofish.com/*
// @grant        none
// @icon         https://img.alicdn.com/tps/i3/TB1eW1eGXXXXXXAXFXXBS8UGFXX-41-22.png

// ==/UserScript==

(function() {
    'use strict';

    const currentUrl = window.location.href; // get the current URL
    const regex = /https:\/\/h5\.m\.goofish\.com\/item\?id=(\d+)/; // regex pattern to match the Goofish link
    const match = regex.exec(currentUrl); // search for the Goofish link using regex

    if (match !== null) {
        const itemId = match[1]; // get the item ID number from the regex match
        const newUrl = `https://item.taobao.com/item.htm?id=${itemId}`; // create the new Taobao URL
        window.location.href = newUrl; // redirect to the new Taobao URL
    }
})();