1688商品页自动添加version参数

当打开1688商品详情页时,自动在URL末尾添加&version=0并刷新

// ==UserScript==
// @name         1688商品页自动添加version参数
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  当打开1688商品详情页时,自动在URL末尾添加&version=0并刷新
// @author       Your Name
// @match        *://detail.1688.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 获取当前页面的URL
    let currentUrl = window.location.href;

    // 检查URL中是否已经包含version参数
    if (currentUrl.indexOf('version=') === -1) {
        // 检查URL中是否已经有问号(?),决定使用&还是?连接参数
        let separator = currentUrl.indexOf('?') !== -1 ? '&' : '?';

        // 构建新的URL
        let newUrl = currentUrl + separator + 'version=0';

        // 跳转到新的URL
        window.location.href = newUrl;
    }
})();