// ==UserScript== // @name 我家在... 改 // @namespace https://114514.plus/ // @version 0.1.8 // @description 自动修改淘宝/天猫/京东等购物页面的“配送至”地址,在你分享商品截图的时候保护隐私。 // @author jkfujr // @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 // @downloadURL none // ==/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 taobaoAddressElement = document.querySelector("[class^='Oo3vRXl7BS--select-trigger--']"); if (taobaoAddressElement) { var originalText = taobaoAddressElement.textContent.trim(); // 获取原始文本并去除首尾空格 var replacementText = fakeAddress1; // 默认为单地址 if (originalText.includes(' ')) { // 如果原始文本包含空格,认为是双地址 replacementText = fakeAddress1 + " " + fakeAddress2; } taobaoAddressElement.textContent = replacementText; taobaoAddressElement.title = replacementText; } 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')); } } })();