Greasy Fork

Greasy Fork is available in English.

Spent on Ali

Get full amount of money spent on products

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Spent on Ali
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Get full amount of money spent on products
// @author       Peter Willemsen <[email protected]>
// @match        https://trade.aliexpress.com/orderList.htm?*
// @match        https://trade.aliexpress.com/orderList.htm
// @grant GM_setValue
// @grant GM_getValue
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// ==/UserScript==

var kFullPrice = "full_price"
var kStarted = "started"
this.$ = this.jQuery = jQuery.noConflict(true);
$(function() {
    var $btn = $("<input type='button' value='Check full spend amount'/>");
    $btn.click(function() {
        GM_setValue(kFullPrice, 0);
        GM_setValue(kStarted, true);
        window.location.reload();
    });
    $('#simple-search').append($btn);
});

(function() {
    if(!GM_getValue(kStarted, false)) {
        return;
    }
    var floatify = function(text) {
        return parseFloat(text.replace(",", ".").replace(/[^\d.-]/g, ''));
    };
    var countOrdersTick = function() {
        var currentPrice = 0;
        $("p.amount-num").each(function() {
            currentPrice += floatify($(this).text());
        });
        console.log("current page price: " + currentPrice);
        var fullPrice = GM_getValue(kFullPrice, 0);
        GM_setValue(kFullPrice, fullPrice + currentPrice);
        console.log("current full price: " + (fullPrice + currentPrice));
        var $nextBtn = $("a.ui-pagination-next.ui-goto-page:first")
        if($nextBtn.length === 0) {
         alert('Your total amount spent on AliExpress: ' + (fullPrice + currentPrice).toFixed(2))
         GM_deleteValue(kStarted)
        }
        else {
            $nextBtn.get(0).click()
        }
    }
    setTimeout(countOrdersTick, 1000);
})();