Greasy Fork

Greasy Fork is available in English.

淘宝&天猫一键好评

淘宝&天猫评价页面添加一键好评按钮

当前为 2015-12-11 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        淘宝&天猫一键好评
// @description 淘宝&天猫评价页面添加一键好评按钮
// @version     1.5.2
// @author      JoJunIori
// @namespace   [email protected]
// @grant       unsafeWindow
// @include     http://rate.taobao.com/*
// @include     https://rate.taobao.com/*
// @include     http://ratewrite.tmall.com/*
// @include     https://ratewrite.tmall.com/*
// ==/UserScript==

var host = window.location.host;
var isTB = host === 'rate.taobao.com';
var isTM = host === 'ratewrite.tmall.com';

// 淘宝一键好评
function taobaoFun() {
  var tbParentElem = document.querySelector('.submitbox');
  var tbSubmitBtn = document.querySelector('.J_submit_rate');
  var tbNewDir = document.createElement('button');
  tbNewDir.innerHTML = '一键好评';
  tbNewDir.className = 'tb-rate-btn type-primary tb-rate-btn haoping';
  tbNewDir.style.marginLeft = '50px';
  tbNewDir.onclick = function() {
    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();

    tbSubmitBtn.click();
  };

  tbParentElem.appendChild(tbNewDir);
}

// 天猫一键好评
function tmallFun() {
  var tmParentElem = document.querySelector('.compose-btn');
  var tmSubmitBtn = document.querySelector('.compose-btn [type="submit"]');
  var tmNewDir = document.createElement('button');
  tmNewDir.innerHTML = '一键好评';
  tmNewDir.className = 'tb-rate-btn type-primary tb-rate-btn haoping';
  tmNewDir.style.background = 'white';
  tmNewDir.style.color = '#c40000';
  tmNewDir.style.border = 'inset 1px #c40000';
  tmNewDir.onclick = function() {
    var tmStar = document.querySelectorAll('[data-star-value="5"]');
    for (var i = 0, a; a = tmStar[i++];) {
      a.click();
    }

    tmSubmitBtn.click();
  };

  console.log(tmParentElem);
  console.log(tmNewDir);
  tmParentElem.appendChild(tmNewDir);
}

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);
  }
}