Count Thumbtack costs

Count total costs on Thumbtack on the payments screen

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Count Thumbtack costs
// @namespace    http://tampermonkey.net/
// @version      2024-08-01
// @description  Count total costs on Thumbtack on the payments screen
// @author       You
// @match        https://www.thumbtack.com/profile/payments/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=thumbtack.com
// @grant        none
// @license      MIT
// ==/UserScript==

function getElementByXpath(path) {
    return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}

function waitForElm(selector) {
    return new Promise(resolve => {
        if (getElementByXpath(selector)) {
            return resolve(getElementByXpath(selector));
        }

        const observer = new MutationObserver(mutations => {
            if (getElementByXpath(selector)) {
                resolve(getElementByXpath(selector));
                observer.disconnect();
            }
        });

        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    });
}

(async function() {
    'use strict';


    window.onkeypress = async function(event) {
        if (event.keyCode == 96) { // Keycode 96 is ` (back quote)
            console.log("Keypress");
            var amounts = 0.0;
            var amount;
            while (getElementByXpath("//div[contains(@class, \"b black\")]")) {
                amount = getElementByXpath("//div[contains(@class, \"b black\")]");
                amount.remove();
                amounts = amounts + parseFloat(amount.textContent.replace("$", ""));
            }
            console.log(amounts);
            console.log("Ended loop");
        }
    }
})();