我家在... 改

自动修改淘宝/天猫/京东等购物页面的“配送至”地址,在你分享商品截图的时候保护隐私。

// ==UserScript==
// @name         我家在... 改
// @namespace    https://114514.plus/
// @version      0.1.7
// @description  自动修改淘宝/天猫/京东等购物页面的“配送至”地址,在你分享商品截图的时候保护隐私。
// @author       
// @match        https://item.jd.com/*.html*
// @match        https://cart.jd.com/cart_index*
// @match        https://*.detail.tmall.com/item.htm*
// @match        https://*.detail.tmall.hk/hk/item.htm*
// @match        https://item.taobao.com/item.htm*
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// @grant        GM_getValue
// @grant        GM_setValue
// @license      GNU GPLv3
// ==/UserScript==

(function () {
    "use strict";

    var fakeAddress1 = "日本";
    var fakeAddress2 = "下北沢";

    if (GM_getValue('addressSpoofing') === undefined) {
        GM_setValue('addressSpoofing', true);
    }
    if (GM_getValue('jdCartAddressSpoofing') === undefined) {
        GM_setValue('jdCartAddressSpoofing', true);
    }
    if (GM_getValue('addressSpoofingDelay') === undefined) {
        GM_setValue('addressSpoofingDelay', 2500);
    }
    if (GM_getValue('jdCartAddressSpoofingDelay') === undefined) {
        GM_setValue('jdCartAddressSpoofingDelay', 2500);
    }

    // 注册(不可用)菜单
    function registerMenu() {
        if (window.toggleMenuCommand) GM_unregisterMenuCommand(window.toggleMenuCommand);
        if (window.toggleJDCartMenuCommand) GM_unregisterMenuCommand(window.toggleJDCartMenuCommand);
        if (window.spoofingDelayCommand) GM_unregisterMenuCommand(window.spoofingDelayCommand);
        if (window.jdCartDelayCommand) GM_unregisterMenuCommand(window.jdCartDelayCommand);

        var addressSpoofing = GM_getValue('addressSpoofing');
        var jdCartAddressSpoofing = GM_getValue('jdCartAddressSpoofing');
        var addressSpoofingDelay = GM_getValue('addressSpoofingDelay');
        var jdCartAddressSpoofingDelay = GM_getValue('jdCartAddressSpoofingDelay');

        var menuText = (addressSpoofing ? '✅ ' : '❌ ') + 'ALL-商品界面';
        window.toggleMenuCommand = GM_registerMenuCommand(menuText, function () {
            GM_setValue('addressSpoofing', !addressSpoofing);
            registerMenu();
            location.reload();
        });

        window.spoofingDelayCommand = GM_registerMenuCommand(`#️⃣ALL-商品界面-延迟`, function () {
            var delay = prompt("请输入伪装延迟时间 (毫秒):", addressSpoofingDelay);
            if (delay !== null) {
                GM_setValue('addressSpoofingDelay', parseInt(delay) || 2500);
                registerMenu();
            }
        });

        var jdCartMenuText = (jdCartAddressSpoofing ? '✅ ' : '❌ ') + '京东-购物车';
        window.toggleJDCartMenuCommand = GM_registerMenuCommand(jdCartMenuText, function () {
            GM_setValue('jdCartAddressSpoofing', !jdCartAddressSpoofing);
            registerMenu();
            location.reload();
        });

        window.jdCartDelayCommand = GM_registerMenuCommand(`#️⃣京东-购物车-延迟`, function () {
            var delay = prompt("请输入京东购物车伪装延迟时间 (毫秒):", jdCartAddressSpoofingDelay);
            if (delay !== null) {
                GM_setValue('jdCartAddressSpoofingDelay', parseInt(delay) || 2500);
                registerMenu();
            }
        });
    }

    registerMenu();

    if (GM_getValue('addressSpoofing')) {
        setTimeout(function () {
            switch (window.location.host) {
                case "item.jd.com":
                    var jdAddressElement = document.querySelector(".ui-area-text");
                    if (jdAddressElement) {
                        jdAddressElement.innerText = fakeAddress1 + " " + fakeAddress2;
                    }
                    break;
                case "detail.tmall.com":
                case "detail.tmall.hk":
                case "chaoshi.detail.tmall.com":
                case "item.taobao.com":
                    var addressElement1 = document.querySelector("[class^='mui-addr-tri-1--']");
                    var addressElement2 = document.querySelector("[class^='mui-addr-tri-2--']");

                    // 单地址
                    if (addressElement1 && !addressElement2) {
                        addressElement1.textContent = fakeAddress1;
                    }

                    // 双地址
                    if (addressElement1 && addressElement2) {
                        addressElement1.textContent = fakeAddress1;
                        addressElement2.textContent = fakeAddress2;
                    }
                    break;
            }
        }, GM_getValue('addressSpoofingDelay'));
    }

    if (GM_getValue('jdCartAddressSpoofing')) {
        if (window.location.host === 'cart.jd.com' && window.location.pathname === '/cart_index') {
            setTimeout(function () {
                var jdCartAddressElement = document.querySelector('.ui-area-text');
                if (jdCartAddressElement) {
                    jdCartAddressElement.innerText = fakeAddress1 + fakeAddress2;
                }
            }, GM_getValue('jdCartAddressSpoofingDelay'));
        }
    }

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址