Greasy Fork is available in English.
amazon!
当前为
// ==UserScript==
// @name hho-amazon-extension
// @namespace https://www.amazon*
// @version 0.1
// @description amazon!
// @author miaomiao
// @match https://www.amazon.co.jp/*
// @icon https://www.google.com/s2/favicons?domain=amazon.co.jp
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
var $ = window.$
$(document).ready(function() {
// 添加按钮
const button = '<button style="position: fixed; top: 100px; right: 100px;z-index: 99999;background: red;color: #fff;" id="hhoBtn">一键上架</button>'
$('body').append(button);
})
// 点击 一键上架
$(document).on('click',"#hhoBtn", function(){
saveHtml();
});
function saveHtml() {
// 获取 html 数据
const arr = decodeURIComponent(location.pathname).split('/')
const index = arr.indexOf('dp')
if (index < 0) {
alert('监测到不是亚马逊详情页哦,如果确认是详情页请联系管理员');
} else {
// 是详情页
const filename = arr[index + 1]
// 点击所有缩略图
$('#altImages li').each(function() { $(this).click() })
// 滚动到底部
var h = $(document).height() - $(window).height()
$(document).scrollTop(h);
console.log(`${filename} is downloading ...`)
$('#hhoBtn').text('正在上传')
var myBlob = new Blob([document.documentElement.innerHTML], { "type" : "text\/html" });
var formData = new FormData()
formData.append('source', 'amazon')
formData.append('filename', filename)
formData.append('file', myBlob)
// 发送请求
$.post({
url: "https://192.168.1.23/upload/amazon",
processData: false,
contentType: false,
data: formData,
success: function(data) {
if (data.success) {
alert('上传成功');
$('#hhoBtn').text('一键上架')
console.log(`${filename} is completed`)
} else {
alert('上传失败');
$('#hhoBtn').text('一键上架')
}
},
fail: function(err) {
alert('上传失败');
$('#hhoBtn').text('一键上架')
console.error(`${filename} is download failed, ${err}`)
}
})
}
}
})();