Add buttons to redirect between Amiami.jp and Amiami.com.
目前為
// ==UserScript==
// @name Amiami Redirect Button
// @name:zh-CN Amiami跳转按钮
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Add buttons to redirect between Amiami.jp and Amiami.com.
// @description:zh-cn 在Amiami商品页右下角添加一个实现amiami.jp与amiami.com互相跳转的按钮。
// @author Mr_Ebonycat
// @match https://www.amiami.jp/top/detail/detail?scode=*
// @match https://www.amiami.com/cn/detail/?scode=*
// @match https://www.amiami.com/eng/detail/?scode=*
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// 从当前页面URL中提取scode
const urlParams = new URLSearchParams(window.location.search);
const scode = urlParams.get('scode');
// 根据当前页面的URL决定跳转的URL
const jpUrl = `https://www.amiami.jp/top/detail/detail?scode=${scode}`;
const engCnUrl = `https://www.amiami.com/detail/?scode=${scode}`;
// 创建按钮
const redirectButton = document.createElement('button');
redirectButton.style.position = 'fixed';
redirectButton.style.bottom = '20px';
redirectButton.style.right = '20px';
redirectButton.style.zIndex = '9999';
redirectButton.style.padding = '2px 4px';
redirectButton.style.border = 'none';
redirectButton.style.backgroundColor = '#4CAF50';
redirectButton.style.color = 'white';
redirectButton.style.borderRadius = '5px';
redirectButton.style.cursor = 'pointer';
// 添加点击事件
if (window.location.href.includes('amiami.jp')) {
redirectButton.textContent = 'Go to COM';
redirectButton.addEventListener('click', function() {
window.location.href = engCnUrl;
});
} else if (window.location.href.includes('amiami.com')) {
redirectButton.textContent = window.location.href.includes('eng') || window.location.href.includes('cn') ? 'Go to JP' : '';
redirectButton.addEventListener('click', function() {
window.location.href = jpUrl;
});
}
// 将按钮添加到页面中
if (redirectButton.textContent) {
document.body.appendChild(redirectButton);
}
})();