Greasy Fork is available in English.
Generate Amazon ASIN links from input and open corresponding pages
当前为
// ==UserScript==
// @name Amazon ASIN Links
// @namespace your-namespace
// @version 1.0
// @description Generate Amazon ASIN links from input and open corresponding pages
// @author Your Name
// @match https://www.amazon.com/*
// @match https://www.amazon.ca/*
// @match https://www.amazon.co.uk/*
// @match https://www.amazon.de/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Create a button for opening single ASIN page
function createOpenASINButton() {
const button = document.createElement('button');
button.innerHTML = '打开ASIN详情页';
button.style.position = 'fixed';
button.style.left = '10px';
button.style.top = '50px';
button.addEventListener('click', function() {
const asin = prompt('请输入ASIN');
if (asin) {
const link = window.location.origin + '/dp/' + asin;
window.open(link);
}
});
document.body.appendChild(button);
}
// Create a button for opening batch ASIN page
function createOpenBatchASINButton() {
const button = document.createElement('button');
button.innerHTML = '打开批量ASIN';
button.style.position = 'fixed';
button.style.left = '10px';
button.style.top = '90px';
button.addEventListener('click', function() {
const asinInput = prompt('请以换行符分隔输入ASIN');
if (asinInput) {
const asins = asinInput.split('\n');
const link = window.location.origin + '/s?rh=p_78%3A' + asins.join('%7C');
window.open(link);
}
});
document.body.appendChild(button);
}
// Check the current domain and create appropriate buttons
const currentURL = window.location.href;
if (currentURL.includes('amazon.com')) {
createOpenASINButton();
createOpenBatchASINButton();
} else if (currentURL.includes('amazon.ca')) {
createOpenASINButton();
createOpenBatchASINButton();
} else if (currentURL.includes('amazon.co.uk')) {
createOpenASINButton();
createOpenBatchASINButton();
} else if (currentURL.includes('amazon.de')) {
createOpenASINButton();
createOpenBatchASINButton();
}
})();