// ==UserScript==
// @name [Neko0] 淘宝天猫一键好评
// @description 淘宝&天猫评价页面添加一键好评按钮
// @version 1.6.2
// @author JoJunIori
// @namespace neko0-web-tools
// @homepageURL https://github.com/nekozero/neko0-web-tools
// @supportURL https://github.com/nekozero/neko0-web-tools/issues
// @grant none
// @run-at document-idle
// @license AGPLv3
// @require https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.0/jquery.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.1/js/solid.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.1/js/fontawesome.min.js
// @include *://rate.taobao.com/*
// @include *://ratewrite.tmall.com/*
// @downloadURL none
// ==/UserScript==
// 初始化设定
let settingValueList = {
// 评价语列表
rateMsgListText: ['质量非常好,与卖家描述的完全一致,非常满意,真的很喜欢,完全超出期望值,发货速度非常快,包装非常仔细、严实,物流公司服务态度很好,运送速度很快,很满意的一次购物。掌柜好人,一生平安。'],
};
for (let obj in settingValueList) {
if (localStorage.getItem(obj) === null) {
localStorage.setItem(obj, settingValueList[obj]);
}
}
// Math.floor(Math.random()*10);
// 置入Style
let style = ``
$('head').append(style)
// 置入DOM
let dom = `
更新
`
$('body').append(dom)
// 绑定点击事件
$('.n-box .button.switch').click(() => {
$('.n-box').toggleClass('open')
})
$('.n-box .button.update.rate-msg-list-text').click(() => {
localStorage.setItem('rateMsgListText', $('#rateMsgListText').val())
})
// 写入已存储的评价语
$('#rateMsgListText').val(localStorage.getItem('rateMsgListText'))
// 监听字数
$('.word-count').text($('#rateMsgListText').val().length)
$('#rateMsgListText').bind('input propertychange', function() {
$('.word-count').text($(this).val().length)
});
var host = window.location.host;
var isTB = host === 'rate.taobao.com';
var isTM = host === 'ratewrite.tmall.com';
// 淘宝一键好评
function taobaoStar() {
var tbGoodRate = document.querySelectorAll('.good-rate');
for (var i = 0, a; a = tbGoodRate[i++];) {
a.click();
}
var tbStar = document.querySelectorAll('.ks-simplestar img');
tbStar[4].click();
tbStar[9].click();
tbStar[14].click();
}
function taobaoMsg() {
var tbRateMsg = document.querySelectorAll('.rate-msg');
for (var i = 0, a; a = tbRateMsg[i++];) {
a.value = localStorage.getItem('rateMsgListText')
}
}
function taobaoFun() {
let elemStar = ``
$('.submitbox').after(elemStar)
$('.tb-btn.star').click(() => { taobaoStar() })
$('.tb-btn.msg').click(() => { taobaoMsg() })
$('.tb-btn.starmsg').click(() => {
taobaoMsg()
taobaoStar()
})
$('.tb-btn.haoping').click(() => {
taobaoMsg()
taobaoStar()
setTimeout(() => {
$('.J_submit_rate').click();
}, 500);
})
}
// 天猫一键好评
function tmallStar() {
var tmStar = document.querySelectorAll('[data-star-value="5"]');
for (var i = 0, a; a = tmStar[i++];) {
a.click();
}
}
function tmallMsg() {
document.querySelector('.J_textInput').shadowRoot.querySelector('#textEditor').shadowRoot.querySelector('#textEl').value = localStorage.getItem('rateMsgListText')
}
function tmallFun() {
let elemStar = ``
$('.compose-submit').after(elemStar)
$('.tm-btn.star').click(() => { tmallStar() })
$('.tm-btn.msg').click(() => { tmallMsg() })
$('.tm-btn.starmsg').click(() => {
tmallMsg()
tmallStar()
})
$('.tm-btn.haoping').click(() => {
tmallMsg()
tmallStar()
setTimeout(() => {
$('.compose-btn [type="submit"]').click();
}, 500);
})
}
if (isTB) {
taobaoFun();
} else if (isTM) {
var timer = setInterval(detection, 1000);
detection();
}
function detection() {
var haoping = document.querySelector('.haoping');
if (!haoping) {
tmallFun();
} else {
clearInterval(timer);
}
}