Skip to content

Commit 39e71a7

Browse files
authored
Create tmallSharedUrl.user.js
1 parent a956bd1 commit 39e71a7

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

JavaScript/tmallSharedUrl.user.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// ==UserScript==
2+
// @name Tmall URL Redirect
3+
// @namespace https://mt25cyb.github.io/
4+
// @version 0.3
5+
// @description Tmall URL Redirect
6+
// @author martin
7+
// @match https://*.tmall.com/*
8+
// @match https://*.taobao.com/*
9+
// @grant none
10+
// ==/UserScript==
11+
12+
(function() {
13+
'use strict';
14+
15+
// 获取原网址的商品 ID
16+
const urlParams = new URLSearchParams(window.location.search);
17+
const itemId = urlParams.get('id');
18+
19+
// 检查是否包含商品 ID 且不匹配排除的网址
20+
if (itemId && window.location.href !== 'https://main.m.taobao.com/detail/index.html?id=' + itemId) {
21+
// 构建新的 Taobao 网址
22+
const newUrl = `https://main.m.taobao.com/detail/index.html?id=${itemId}`;
23+
24+
// 跳转到新的网址
25+
window.location.href = newUrl;
26+
}
27+
})();

0 commit comments

Comments
 (0)